CS102 Lab2

Due: Feb 26th (Sunday)


In this lab you will build a simple calculator as a swing application.


The high level objectives of this lab are:

What you must do:

You must build a graphical calculator that will allow you to do simple arithmetic. Your calculator needs to allow a user to input multi digit numbers. (For the sake of easier programming, you may assume that the user will never type in more than an 8 digit number, though you need not enforce this.) Your calculator should accept numeric input only when you press one of the number buttons with the mouse (that is you must prohibit the user from typing directly into any JTextField that you have. (use setEnabled(false) on the field.). When an arithmetic operation is selected, keep track of the current number in your display, zero out the display, and keep track of the current operation. When the equals button is pressed, take the current number in the display, the stored number and the stored operation, and apply the operation to the two numbers, then display the result in the display field. A sample user interface for this program is shown below.

You may use any other user interface that you find easy to make and functions well as a calculator.

Extra Requirements:

You must satisfy the following constraints on your program


When your program is ready, you need to write a readme.txt file that provides me the following information:

When your readme and your code is ready, zip up your files and email them to me as you did in the last lab.