Calculator
-
This applet looks best in Netscape Navigator 4.5.
-
I decided to implement the calculator applet for this assignment.
-
The problem was to design a calculator that could perform addition on two
integers that a user enters, and return that result in a TextField ( using
the AWT ) on the visible applet.
-
The calculator I implemented can perform addition, subtraction, multiplication,
and division.
-
Division by zero is not allowed.
-
Only one operation can be performed at a time. For instance, if you add
two numbers, and then you wish to subtract two other numbers you must first
hit clear.
-
After performing one operation, you cannot use the result in the next operation
without hitting clear first and then reentering the result.
-
I could have implemented the calculator to allow for this manipulation,
but that would have made it exceedingly more difficult than the desired
assignment.
-
Using a combination of BorderLayout and GridLayout, I set up the design
of the calculator.
-
Using actionPerformed, I handled each case of operation, as well as the
clear and equals buttons.
by Greg (Sterge) Johnson