Reykjavik University Calculator Program
Description
Having Trouble Meeting Your Deadline?
Get your assignment on Reykjavik University Calculator Program completed on time. avoid delay and – ORDER NOW
Write a program which allows the user to repeatedly input a simple expression, consisting of one operator and two integer operands, until the input is “q”. The result of the expression is printed (with two digits after the decimal point), given that the expression does fulfil the following:
Valid operators are +, -, * and / Valid operands consists only of digits If the operator is / (division), then the second operand cannot be 0
In each iteration, the following appropriate error message is printed if an error is found, otherwise the result of the expression is printed.
“Invalid operator” “Invalid operands” “Can’t divide by 0”
You are neither allowed to use the eval() function nor import operator in your implementation. The material you need to use in this project is in chapters 1-4 in the textbook.
Example input/output:
Enter an equation: 12 + 9
Result: 21.00
Enter an equation: 7 / 3
Result: 2.33
Enter an equation: 11 – 23
Result: -12.00
Enter an equation: 5 / 2
Result: 2.50
Enter an equation: 6 / 0
Can’t divide by 0
Enter an equation: 3 * zz
Invalid operands
Enter an equation: 3 x 4
Invalid operator
Enter an equation: 100 + 50
Result: 150.00
Enter an equation: q
The lines with “Enter an equation” are inputs, the other are outputs.
You MUST use a format string (or an f-string) when you print “Result: …”, and write the result using a precision of two digits.
You can assume that the input is always “correctly” formatted, i.e. with spaces between the operator and the operands.