Problem Solving: Calculator Using the if and switch Statement

In this lesson, we will think of a solution together to write a program that takes two operands with one operator and prints results.

A simple calculator program

Write and run a program that simulates a simple calculator. It should read two integers and a character. If the character is a +, the sum will be printed; if it is a -, the difference will be printed. If it is a *, the product will be printed. If it is a /, the quotient will be printed. If it is a %, the remainder will be printed.

Sample Input

5 * 5

Sample output

25

Get hands-on with 1200+ tech skills courses.