import java.util.Scanner;
public class SimpleCalc {
public static void main(String args[]) {
double a, b, c;
Scanner scn = new Scanner(System.in);
System.out.println("\n1. Add");
System.out.println("2. Subtract");
System.out.println("3. Multiply");
System.out.println("4. Divide\n");
System.out.print("Please make a selection: ");
int function = scn.nextInt();
System.out.print("\nA = ");
a = scn.nextDouble();
System.out.print("B = ");
b = scn.nextDouble();
switch(function) {
case 1:
c = a + b;
System.out.println(a + " + " + b + " = " + c);
break;
case 2:
c = a - b;
System.out.println(a + " - " + b + " = " + c);
break;
case 3:
c = a * b;
System.out.println(a + " * " + b + " = " + c);
break;
case 4:
c = a / b;
System.out.println(a + " / " + b + " = " + c);
break;
}
}
}
public class SimpleCalc {
public static void main(String args[]) {
double a, b, c;
Scanner scn = new Scanner(System.in);
System.out.println("\n1. Add");
System.out.println("2. Subtract");
System.out.println("3. Multiply");
System.out.println("4. Divide\n");
System.out.print("Please make a selection: ");
int function = scn.nextInt();
System.out.print("\nA = ");
a = scn.nextDouble();
System.out.print("B = ");
b = scn.nextDouble();
switch(function) {
case 1:
c = a + b;
System.out.println(a + " + " + b + " = " + c);
break;
case 2:
c = a - b;
System.out.println(a + " - " + b + " = " + c);
break;
case 3:
c = a * b;
System.out.println(a + " * " + b + " = " + c);
break;
case 4:
c = a / b;
System.out.println(a + " / " + b + " = " + c);
break;
}
}
}
0 komentar:
Posting Komentar