|
Spring Semester 2002 |
For this assignment you are to write an arithmetic expression evaluator that is able to perform
Here's a sample session with the program:
You may safely assume thatfrilled.cs.indiana.edu%java Eval Eval> 1 + 1 1 + 1 2 Result is: 2 Eval> ( 1 + 2 ) * 3 ( 1 + 2 ) * 3 ( 3 ) * 3 3 * 3 9 Result is: 9 Eval> a = 1 + 1 1 + 1 2 Stored 2 in a Eval> a 2 Result is: 2 Eval> a = a + 1 2 + 1 3 Stored 3 in a Eval> a 3 Result is: 3 Eval> b = a - 4 3 - 4 -1 Stored -1 in b Eval> a 3 Result is: 3 Eval> b -1 Result is: -1 Eval> a = ( a - b ) * ( a + b ) ( 3 - -1 ) * ( 3 + -1 ) ( 4 ) * ( 3 + -1 ) ( 4 ) * ( 2 ) 4 * ( 2 ) 4 * 2 8 Stored 8 in a Eval> a 8 Result is: 8 Eval> b -1 Result is: -1 Eval> b = a + b * 4 8 + -1 * 4 8 + -4 4 Stored 4 in b Eval> a / b 8 / 4 2 Result is: 2 Eval> a = a / b 8 / 4 2 Stored 2 in a Eval> a 2 Result is: 2 Eval> b 4 Result is: 4 Eval> exit frilled.cs.indiana.edu%
Here's a grading scale for this assignment:
| Task | Points |
|---|---|
| Reading the data line by line and storing it properly | 2.0 |
Being able to support + and - | 2.0 |
Supporting * and / | 2.0 |
| Allowing named variables to store values | 1.5 |
| Allowing named variables in expressions | 1.5 |
Providing error-checking through try-catch blocks
| 1.0 |
| Total | 10.0 |
Please let us know if you have any questions.