rahulkarda / java-calculator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Task: “Calculator 2.0”

Description:

Create a console application "Calculator". The application must read the arithmetic operations entered by the user from the console and output the result of their execution to the console. User inputs the whole mathematical expression in ONE line. Solutions that prompt the user to enter digits and operations one by one are NOT eligible.

Requirements:

The calculator can perform addition, subtraction, multiplication and division operations with THREE numbers: a + b - c, a - b + c, a * b - c, a / b * c. Two numbers can also be used as input. The calculator must accept input numbers from 1 to 10 inclusive, no more. At the output, the numbers are not limited in size. The calculator can only work with integers. When the user enters invalid numbers, the application throws an exception and exits. When the user enters a string that does not match one of the above arithmetic operations, the application throws an exception and exits.

Examples:

Input: 5 - 2 + 8

Output: 11

Input: 5 + 8 - 2

Output: 11

Input: 5 - 8 * 2

Output: 11

About


Languages

Language:Java 100.0%