Basically I need to write a program that takes a users input of addition or subtraction expressions (separated by a ";") and give an answer to them. However, I am confused on how I am supposed to get the actual numbers out of the string of text.
The program must take a users input of addition or subtraction expressions ending with a ";" then convert the numbers in the string to integers and complete the expression by giving the answer.
Welcome to the Expression Calculator
Enter a line of expressions:
-5 + 6 - 2 ; 2 – 4– 8; 16 +-18 - -1;
Expression 1: value = -1
Expression 2: value = -10
Expression 3: value = -1
Your program must give error messages in the following cases:
o A missing semi-colon on the last expression
o The use of any operator other than + or -
o Any deviation from the pattern of “number plus/minus number plus/minus …”
There is no restriction on the number of spaces
Thanks a lot guys!