CODE WARS ]I[ PROGRAMMING COMPETITION
Undo Arithmetic
Problem 10 Division I / II 11 Points
Problem Statement
Many commercial programs offer an "undo" feature that allows a user to revert back to a state prior to an operation. Write a simple arithmetic calculator with undo capabilities.
Program Input
Each line of the input file PROG10.IN follows one of these formats:
   number
   operator number
   UNDO
The valid operators are +, -, *, and /. The number will be in %f format (no scientific notation). Operators will be separated from numbers by one or more spaces. The program should allow at least 16 levels of UNDO.
  7.24
  * 94.18
  + 13.6
  / -28.935
  + 0.0122
  UNDO
  UNDO
  / -29.835
  + 0.0122
  UNDO
  + 0.0112
  12.7
  + 3.1
  UNDO
  UNDO
Program Output
The program should write the input line to the output file PROG10.OUT along with the current value in the calculator, as shown below:
7.24              7.24
* 94.18         681.8632
+ 13.6          695.4632
/ -28.935       -24.03536201832
+ 0.0122        -24.02316201832
UNDO            -24.03536201832
UNDO            695.4632
/ -29.835       -23.31031339031
+ 0.0122        -23.29811339031
UNDO            -23.31031339031
+ 0.0112        -23.29911339031
12.7             12.7
+ 3.1            15.8
UNDO             12.7
UNDO            -23.29911339031