Category: Java Simple Programs

JAVA Program to Find Area of Room using Final Variable 0

JAVA Program to Find Area of Room using Final Variable

Follow me JAVA Program to Find Area of Room using Final Variable: // program to use the final variable class Room { final int length=10; int breadth; Room(int y) //constructor mthod { //length=x; breadth=y;...

JAVA Program to make use of Abstract Class 0

JAVA Program to make use of Abstract Class

Follow me JAVA Program to make use of Abstract Class: // program to use the Abstarct class and Method abstract class Person // Abstract class { String name=”John”; int age=25; Person(String n, int a)...

JAVA Program to Accept Numbers and Display in Words 0

JAVA Program to Accept Numbers and Display in Words

Follow me JAVA Program to Accept Numbers and Display in Words: import java.io.*; class num_to_word { public static void main(String args[]) { int n,r,m=0; try { System.out.print(“Enter any number : “); DataInputStream in =...

JAVA Program to Find GCD of Two Numbers 0

JAVA Program to Find GCD of Two Numbers

Follow me JAVA Program to Find GCD of Two Numbers: import java.io.*; class gcd { public static void main(String args[]) { int a,b; a= Integer.parseInt(args[0]); b= Integer.parseInt(args[1]); System.out.println(“a= “+a); System.out.println(“b= “+b); while ( a!=b)...

JAVA Program to Accept Details of Books in Array and Display it 0

JAVA Program to Accept Details of Books in Array and Display it

Follow me JAVA Program to Accept Details of Books in Array and Display it: class books { int bookid,no_of_copies; String author,title; double price; books(int b,String a,String t,int no,double p) { bookid=b; author=a; title=t; no_of_copies=no;...

JAVA Program to Accept Details of Voters in Array and Display it 0

JAVA Program to Accept Details of Voters in Array and Display it

Follow me JAVA Program to Accept Details of Voters in Array and Display it: class voter { String voter_name,voter_address; int votercontactno,voteradhar; voter(String vn, String va,int vcn,int vad) { voter_name=vn; voter_address=va; votercontactno=vcn; voteradhar=vad; } void...

JAVA Program to Calculate Number of Vowel in String 0

JAVA Program to Calculate Number of Vowel in String

Follow me JAVA Program to Calculate Number of Vowel in String: import java.io.*; import java.lang.*; class vowel { public static void main(String args[]) { String s=”This is string”; int cnt=0; for(int i=0;i<s.length();i++) { if(s.charAt(i)==’a’||s.charAt(i)==’e’||s.charAt(i)==’i’||s.charAt(i)==’o’||s.charAt(i)==’u’||...

JAVA Program to Find Area of Rectangle 0

JAVA Program to Find Area of Rectangle

Follow me JAVA Program to Find Area of Rectangle: class rect { int len,wid; int area; rect(int l,int w) { len=l; wid=w; } void area() { System.out.println(“Area of Rectangle is:”+(len*wid)); } public static void...

JAVA Program to Print Odd Numbers up to 100 0

JAVA Program to Print Odd Numbers up to 100

Follow me JAVA Program to Print Odd Numbers up to 100: import java.io.*; class even { public static void main(String args[]) { int n=100; System.out.println(“Odd Numbers are:”); for(int i=1;i<=n;i++) { if(i%2!=0) System.out.println(i); } }...

JAVA Program to Print Even Numbers up to 100 0

JAVA Program to Print Even Numbers up to 100

Follow me JAVA Program to Print Even Numbers up to 100: import java.io.*; class even { public static void main(String args[]) { int n=100; System.out.println(“Even Numbers are:”); for(int i=1;i<=n;i++) { if((i%2)==0) System.out.println(i); } }...