Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1
java_Q_no._1-15..

# java_Q_no._1-15..

Ratings: (0)|Views: 134|Likes:

### Availability:

See more
See less

05/06/2011

pdf

text

original

1.Write a program to print “ Welcome to Java Programming” on thescreen.
class Qno1sol{public static void main(String a[]){System.out.println("Welcome to Java Programming");}}
2.Write a program to find the greatest of the given three numbers.

}if(b>c ){System.out.println(b+" "+"is greatest number");}if(c>a ){System.out.println(c+" "+"is greatest number");}}catch(IOException e){System.out.println("There is problem"+e);}}}
3.Using switch and case statements write a program to add,subtract , multiply and divide the two numbers.
import java.io.*;public class Qno3sol{public static void main(String a[])throws IOException{DataInputStream in=new DataInputStream(System.in);System.out.println("Enter Switch Cases");int i=Integer.parseInt(in.readLine());

//int i=4;int m,n;m=10;n=5;switch(i){case 1:System.out.println("Addition"+" "+(m+n));break;case 2:System.out.println("Substration"+" "+(m-n));break;case 3:System.out.println("Multiplication"+" "+(m*n));break;case 4:System.out.println("Division"+" "+(m/n));break;default:System.out.println("This is not a valid input parameter");break;}}}
4.Using for loop write a program to add the integers up to 50 andprint the result on the screen.
class Qno4sol