Using a switch statement, write a program that prompts the user for a numeric code and two operands. The numeric codes of 1, 2, 3, and 4 represents addition, subtraction, multiplication, and division respectively. Before division, your program should check whether the second operand is not zero. If it is, it should display “Division by zero not allowed” to the screen. Sample Run1 Sample Run 3 Code: 1 Code: 4 Operand1: 5 Operand1: 5 Operand2: 4 Operand2: 0 Output1: Sum = 9 Output3: Division by zero not allowed Sample Run 2 Code: 3 Operand1: 5 Operand2: 4 Output2: Product = 20
Using a switch statement, write a program that prompts the user for a numeric code and two operands. The numeric codes of 1, 2, 3, and 4 represents addition, subtraction, multiplication, and division respectively. Before division, your program should check whether the second operand is not zero. If it is, it should display “Division by zero not allowed” to the screen.
Sample Run1 Sample Run 3
Code: 1 Code: 4
Operand1: 5 Operand1: 5
Operand2: 4 Operand2: 0
Output1: Sum = 9 Output3: Division by zero not allowed
Sample Run 2
Code: 3
Operand1: 5
Operand2: 4
Output2: Product = 20
Step by step
Solved in 3 steps with 1 images