Summary: In this assignment, you will use preexisting classes to implement a simple reverse polish notation (RPN) calculator.
Collaboration: You can work on this assignment in groups of up to size three. You may discuss your design with any size group. You may also work with each other on general debugging issues.
If you work as part of a group, you are responsible for ensuring that all members of the group understand all sections of the assignment.
Implement a simple, integer-based, reverse-polish notation calculator.
You may use the built-in Java Stack class,
Bailey's Stack class, or one of your own devising. Your
calculator should support the four basic operations (addition, subtraction,
multiplication, and division).
The primary part of your interface will look something like
ReadStream stdin = new ReadStream();
...
while (!stdin.eof()) {
Char ch = stdin.peek();
// Push a value on the stack
if (isDigit(ch)) {
nextval = stdin.readInt();
calculator.push(nextval);
}
// Handle operators
else {
operation = stdin.readString();
...
}
} // while
You should print out the intermediate results as you go.
You can receive some (but not a lot of) extra credit by supporting a wider variety of operations. Your operations might be traditional (e.g., exponentiation) or nontraditional (e.g., print the stack). You can receive additional extra credit by supporting a wider variety of types (e.g., floating point numbers in addition to integers).
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Mon Nov 3 09:47:19 1997.
This page generated on Mon Nov 3 10:02:54 1997 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu