Writing a program that reads a string of arithmetic expression from the keyboard and
evaluates the arithmetic operation in the string. Some example runs are given below.
program should accept only
* any real or integer numbers
* four basic arithmetic operators, +, -, *, /
* paranthesis ( , )
I'm just not getting paranthesis, I mean, how I get this expression "(5 + (11-5) * 2) * 4 + 9.9" into the program.
I have an idea about it, but I am not sure it's going to work. My idea is read this expression from the command line to a string and than read that string into a function, like cout<<"Result is:" << A (not the whole thing but I just express myself)
Example 2
Input an aritmetic expression:
2 - 3 * 4 + 2
The result is -8Example 3
Input an aritmetic expression:
(5 + (11-5) * 2) * 4 + 9.9
The result is 77.9Example 4
Input an aritmetic expression:
2 + 3 = 5
Error: Undefined symbol '='.Example 5
Input an aritmetic expression:
(5 + (11-5 * 2) * 4 + 9
Error: Missing paranthesis ')'.Example 6
Input an aritmetic expression:
(5 + 11-5) * 2) * 4 + 9
Error: Missing paranthesis '('.Example 7
Input an aritmetic expression:
2 - p 4 + 2
Error: Undefined symbol 'p'.Example 8
Input an aritmetic expression:
2 - [3.0 / 4] + 2.5
Error: Undefined symbol '