CS 280 Spring 2008

Assignment 2 –Simple GUI and Simple Calculations

100 points

 

Assigned: 01/23/2008

Due: 01/30/2008 at the start of class

 

Pre-Lab (Do Before Lab):  Bring materials – a USB for a take home copy. Plan out your GUI, tasks, objects, and events needed for program.

 

Main Assignment:

Imagine that you are writing a very basic program for an ethical ticket broker.  According to PA state law, tickets can only be sold for 25% above their face value or $5.00 above their face value (whichever is greater). Imagine that they want a program to calculate the maximum price they could legally charge under each of the two provisions, given ticket face value (since we haven’t covered branching yet, leave it to the humans to figure out which is greater).  Write a program that calculates 25% above and $5.00 above face value prices and displays them. Provide capabilities to calculate, clear the text boxes to start again, and to exit.

·         Also, put your name on the GUI form as a jlabel.

·         You’re just beginning at setting up GUIs. Don’t worry too much about making the interface nice.  

 

 

Hand in:

 

Miscellaneous:

o    Define the 25% and $5 as constants, so that if the law changes the program is easy to change. If we haven’t covered that in class yet, Java constants are defined like:

o    We won’t have covered formatting output to show currency or number of decimal places; don’t worry about that.

o    Note that we haven’t done anything yet with making sure the user enters something reasonable – don’t worry about that.

o    MAKE SURE YOUR PROGRAM WORKS! (i.e. gets the correct answers).

o    You MUST include some comments that explain your program in order to get full credit (for this program, these can be pretty minimal).