ICS 211 Assignment 6

Stacks and Infix expression

This assignment requires you to implement an infix calculator according to the directions in Programming project 7 on page (192/301) of the book. Your calculator must be able to compute any expression of floating point numbers using the operands +, -, *, or / (you need not implement parentheses, nor do you need to handle negative input numbers such as "-5"). You are (as before) welcome to create either a graphical user interface or a text-based user interface, as long as your program can accept arbitrary, valid infix expressions using these four operators.

For this project, you are welcome to adapt any code from the book (and only from the book!).

Sample interaction

If using a text-based user interface, your program could behave as follows. The parts your program prints are in this font, the user input is in this font.


calc 2 + 2
4
calc 2.1 + 2.9
5
calc 3 * 3 - 2 - 1
6
calc 1 + 2 + 1.5 * 8 / 3
7

Turning in the Assignment

Email all the java source code for your assignment to the TA following the instructions posted here. Your source code must include all the parts of each class, even if the instructor or the authors of the textbook originally wrote some of the code.