A Calculator with switch
MediumRead an integer, an operator character, and a second integer, written like 12 + 5, and print the expression and its result in the form 12 + 5 = 17, echoing the operator exactly as it was typed. Use a switch on the operator: + adds, - subtracts, x or * multiplies, / divides with integer division, and % gives the remainder. For / and %, if the second operand is 0 print division by zero and return 1. For any other operator print unknown operator and return 1 from the default case. If the three values cannot be read, print invalid input and return 1.
Success Criteria
Your code must pass 10 test case(s) to complete this exercise. 3 hint(s) are available if you need help.
Sign in to track your progress
You can work on exercises as a guest, but sign in to track your progress and save your submissions.
How did you find this exercise?
Your rating helps us improve the content.