Answered step by step
Verified Expert Solution
Question
1 Approved Answer
needs to be in C++ coding sample run1 : Enter the expression: 1 + 26 * 2 % 19 / 5 ? The result is
needs to be in C++ coding
sample run1 :
Enter the expression:
1
+
26
*
2
%
19
/
5
?
The result is 3
dsample run2:
Enter the expression:
12
*
9
-
37
+
-8
?
The result is 63
In the distant and slightly dystopian future, the Grand Poobah has banned the use of hand held calculators. Some say he was hit on the head with one. Others believe it is due to his fear of accountants. Either way, hand calculators are a thing of the past. However, you find yourself in sudden need of a calculator that can perform simple calculations. No worries. You are a C++ programmer and you can write a console application to do this. This program does not serve any practical purpose and is, in fact, a very inefficient way to de- sign a calculator. This exercise is just to give you some practice in writing functions. Specifications . This program makes use of functions. The main function should only contain one line, which is a call to the evaluate function. (5 points) Write 5 functions to perform the 5 basic arithmetic operations: +,-, *, / and %. Give them some sensible name (for example, the function that performs addition can be called add) Each of the functions will take 2 integer arguments and return an integer value. (25 points) Write a function called evaluate, that does not take any arguments and does not returin a value. This method will read in an arbitrary number of values from the user: an integer followed by a character that denotes an operation. Once you have the number and the operation, call the appropriate function from the five that you just wrote to keep a running evaluated total. The user input ends when the character entered is a . When the user is done with input, print the result. (15 points) You may assume that all inputs are valid. You need not test for wrong inputs. Here, you need to ignore the order of operations and calculate the values as they come. . Please include comments wherever appropriate. (5 points)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started