Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1


Ratings: (0)|Views: 134|Likes:
Published by Mukesh Kumar

More info:

Published by: Mukesh Kumar on May 06, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





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.
import java.io.*;class Qno2sol{public static void main(String args[]){try{DataInputStream ds=new DataInputStream(System.in);System.out.println("Enter Your Three Numbers");int a=Integer.parseInt(ds.readLine());int b=Integer.parseInt(ds.readLine());int c=Integer.parseInt(ds.readLine());if(a>b ){System.out.println( a+" "+"is greatest number");
}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

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->