Subscribe For Free Updates!

We'll not spam mate! We promise.

Sunday, 26 August 2012

Calculator code in Java language



import java.util.Scanner;
class calc
{
public static void main(String arg[])
{

Scanner sc=new Scanner(System.in);
int a,b,c;
String opp;
System.out.print("Enter First Value: ");
a=Integer.parseInt(sc.next());
System.out.print("Enter second value: ");
b=Integer.parseInt(sc.next());
System.out.print("Enter opperator : ");
opp=sc.next();
if (opp.equals("+"))
{
System.out.println(a+b);
}
else
if (opp.equals("-"))
{
System.out.println(a-b);
}
else
if (opp.equals("*"))
{
System.out.println(a*b);
}
else
if (opp.equals("/"))
{
System.out.println(a/b);
}
}


}

Socializer Widget By CodingLovers
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment