0% found this document useful (0 votes)
43 views6 pages

Class Abc (Public Static Void Main (String Args ) (System - Out.println (" Hello World") ) )

The document contains 6 Java programs that demonstrate different basic programming concepts: 1) Printing "Hello World", 2) Determining if a number is odd or even, 3) Calculating the area of a circle, 4) Multiplying two double values, 5) Calculating the average of n numbers, 6) Finding the largest of three numbers. Each program contains a main method that takes command line arguments, performs the specified calculation, and prints the result.

Uploaded by

Mohit Miglani
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views6 pages

Class Abc (Public Static Void Main (String Args ) (System - Out.println (" Hello World") ) )

The document contains 6 Java programs that demonstrate different basic programming concepts: 1) Printing "Hello World", 2) Determining if a number is odd or even, 3) Calculating the area of a circle, 4) Multiplying two double values, 5) Calculating the average of n numbers, 6) Finding the largest of three numbers. Each program contains a main method that takes command line arguments, performs the specified calculation, and prints the result.

Uploaded by

Mohit Miglani
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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