003-001-003
Operators: Simple Calculator
Medium
Problem Description
In this problem, you will create a program that reads two integers and an operator (+, -, *, /, or %) from standard input, performs the specified arithmetic operation, and displays the result to standard output.
Problem Overview
Create a simple calculator that inputs two integers and an operator, then displays the calculation result.
Input Format
Receive 3 lines of input:
- First integer
- Second integer
- operator (+, -, *, /, or %)
Output Format
Display the result in the following format:
[number1] [operator] [number2] = [result]
```java
## Notes
- Integer division truncates decimal places
- Display "Invalid operator" for invalid operators.
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up