import java.util.Scanner;
public class operator {
public static void main (String args[])
{
Scanner s = new Scanner (System.in);
System.out.println (" Enter two number:");
int sum,minus, product, multiple;
float divide;
int x =s.nextInt();
int y =s.nextInt();
System.out.println (" Enter the desire operator | + | - | / | * | % |:");
String operator = s.next();
if (operator.equals( "+"))
{sum = x+y;
System.out.println (" The sum of the 2 number is "+sum);}
else if (operator.equals ("-"))
{minus = x-y;
System.out.println (" The minus of the 2 number is "+minus);}
else if (operator.equals ("/"))
{divide = x/y;
System.out.println (" The divide of the 2 number is "+divide);}
else if (operator.equals ("*"))
{product = x*y;
System.out.println (" The product of the 2 number is "+product);}
else if (operator.equals ("%"))
{multiple = x%y;
System.out.println (" The product of the 2 number is "+multiple);}
}
}
Friday, 6 February 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment