public static void main(String[] args) {
double Num1,Num2,Result=0;
char op;
Scanner In = new Scanner (System.in);
System.out.print("Enter First Number: ");
Num1 = In.nextDouble();
System.out.print("Please Choose: ");
System.out.print("'+','-','*','/','%' : ");
op = In.next().charAt(0);
System.out.print("Enter Second Number: ");
Num2 = In.nextDouble();
switch (op) {
case '+': Result = Num1 + Num2; break;
case '-': Result = Num1 - Num2; break;
case '*': Result = Num1 * Num2; break;
case '/': Result = Num1 / Num2; break;
default : System.out.printf("Enter Wrong");
}
System.out.println("Result: " + Result);
}
}
0 comments:
Post a Comment