CSE 11 Spring 2001
Homework #5

Required reading: Savitch text Chapters 12 and 14

Turn in due date: Thursday, May 17
Interview due date: Tuesday, May 22

Note: You can do this and take an interview without turning in the assignment, as long as it is before the
turnin deadline (and until the deadline is announced it is definitely before the deadline).

Programming:
You may work in teams of two students, but once you form a team, you cannot change the team for this assignment. You may work alone if you prefer.

Write a GUI with the look and feel of a hand held calculator. Use the Adder GUI, Display 12.19 in the text as a model. Your calculator should handle addition, subtraction, multiplication, and division. It should have a reset button to start over again. If the user tries to divide by zero, it should display an error message. Your calculator should be able to save and later recall two different values. It recalls them one at a time, so there is a memory1 button and a memory2 button, as well as save buttons. To do a running arithmetic calculation like: 2+3-4*6/23 note that it does not parse the input.

For example:


it gets a 2 then a +
and calculates 0 + 2 to get 2
It then gets a 3 and +
and calculates 2 + 3 to get 5
it then gets a 4 and -
and calculates 5 - 4 to get 1
it then gets a 6 and *
and calculates 1*6 to get 6
etc.

Unlike the example in the text, your GUI will use a keypad to enter numbers.

Call your class Calculator, so the file is Calculator.java. You only turn in Calculator.java. You do not turn in any icon file(s), but have the icon files ready in your account so the proctor can see them and run your program with the icons. You will use the class NumberFormatException, but you do not turn in this exception class. It is a predefined class that is
in the standard Java libraries.