V22.0002 - ASSIGNMENT 4


You are to write a program that evaluates simple arithmetic expressions which are composed by positive numbers (real or integers) and the four basic arithmetic operators: +, -, * and /. The program will have to adhere to the following rules:

  1. The expressions will be evaluated left to right (all operators will have the same precedence).
  2. Blank spaces are ignored.
  3. The expression is terminated by the end of the line, at which point you will display the answer.
  4. The prompt is indicated with >.
  5. You have to guard against illegal characters entered.
  6. The program can be terminated only by pressing <CTRL-C>.

Ex:

    > 2 + 3 * 4/6
    3.333333
    > 2/4+3
    3.500000
    > 2!/4+3  
    *** Illegal character !
    > 
Notes and Hints: