Write an integer calculator. This should be able to handle +, -, / (integer divi
ID: 3669510 • Letter: W
Question
Write an integer calculator. This should be able to handle +, -, / (integer division), and *(integer multiplying) until a '#' character is reached instead of an operation. Ignore order of operations as well, and always assume the left operations are done first. For eample: 2+3/5 = 5/5 = 1. You should then show the result (you do not need to show the original equation). As this is an integer calculator you may assume they enter only integers and valid operations (or the stopping character). Detect an error if you enter just a '#'.
Example 1(user input is underlined):
Enter an equation: 2+3*2#
10
Example 2 (user input is underlined):
Enter an equation: 2+3*2/5000+94#
5
Example 3 (user input is underlined):
Enter an equation: 2/3#
0
Example 4 (user input is underlined):
Enter an equation: 7#
7
Example 5 (user input is underlined):
Enter an equation: #
Error
Explanation / Answer
#include "calculator.hpp" #include #include #include #define STR1(s) #s #define TOSTRING(s) STR1(s) /// Test expressions #define EXPR1 45345 + 0 + 0xdf234 - 1000 % 7 #define EXPR2 (0 + 0xdf234 - 1000) * 3 / 2 % 999 #define EXPR3 1Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.