import java.io.*;
public class Calculus
{
public static void main(String []w) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter The First Integer :- ");
String x=br.readLine();
int y=Integer.parseInt(x);
System.out.println();
System.out.print("Enter The Second Integer:- ");
x=br.readLine();
int z=Integer.parseInt(x);
System.out.println();
System.out.println("Enter Your Choice");
System.out.println();
System.out.println("1.Addition");
System.out.println("2.Substraction");
System.out.println("3.Multiplication");
System.out.println("4.Division");
x=br.readLine();
int choice=Integer.parseInt(x);
switch (choice)
{
case 1:
System.out.println(y+"+"+z+"="+(y+z));
break;
case 2:
System.out.println(y+"-"+z+"="+(y-z));
break;
case 3:
System.out.println(y+"x"+z+"="+(y*z));
break;
case 4:
System.out.println(y+"/"+z+"="+(y/z));
break;
default:System.out.println("Enter listed choices....");
}
}
}
Wednesday, February 25, 2009
Sample java code for Calculator
Labels:sreejithrs,nojamp,karakulam,sreejith rs
BufferedReader,
calculator,
java sample code,
user inputs
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment