In this Java program, you’ll learn how to make a simple calculator using a switch..case
statement. This calculator would be able to perform these operations such as add, subtract, multiply and divide two numbers. In this program, we used the following Java basics such as switch..case
statement.
Here is the code of the program to make a simple calculator using a switch..case statement.
Choose an operator: +, -, *, or /
+
Enter first number
52
Enter second number
52
52.0 + 52.0 = 104.0
Choose an operator: +, -, *, or /
-
Enter first number
100
Enter second number
40
100.0 - 40.0 = 60.0
Choose an operator: +, -, *, or /
/
Enter first number
100
Enter second number
5
100.0 / 5.0 = 20.0
Comments