You are on page 1of 6

Q: - WAP to print Hello word on the screen. class abc{ public static void main( String args[]) { System.out.

println(" Hello world"); } }

Q: - WAP to enter a number and find whether it is odd or even. class num { public static void main( String args[]) { int a; a=Integer.parseInt(args[0]); if(a%2==0) System.out.println(" Number is Even"); else System.out.println(" Number is Odd"); } }

Q: - WAP to enter radius and find area of the circle. class ar { public static void main( String args[]) { int a; double b; a=Integer.parseInt(args[0]); b=3.14*a*a; System.out.println(" Area of circle is:"+b ); } }

Q: - WAP to enter two double arguments. Multiply them together and display the result. class mul { public static void main( String args[]) { double a,b,c; a=Double.parseDouble(args[0]); b=Double.parseDouble(args[1]); c=a*b; System.out.println("Multiplication of number is:"+c ); } }

Q: - WAP to find average of n numbers. class avg1 { public static void main( String args[]) { int n,i; double avg=0; n=Integer.parseInt(args[0]); for(i=1;i<=n;i++) { avg+=i; } avg=avg/n; System.out.println("Average of numbers is" +avg); } }

Q: - WAP to find the largest of three numbers. class big { public static void main( String args[]) { int a,b,c; a=Integer.parseInt(args[0]); b=Integer.parseInt(args[1]); c=Integer.parseInt(args[2]); if((a>b)&&(a>c)) { System.out.println("Largest of three numbers is:"+a ); } else if((b>a)&&(b>c)) { System.out.println("Largest of three numbers is:"+b ); } else if((c>a)&&(c>b)) { System.out.println("Largest of three numbers is:"+c ); } } }

You might also like