EECS 370

Machine Problem 5, Spring 2000

Heads and Tails

Due: Monday, April 10, 2000 at 11:59 pm

For this assignment, you are to create a simple Graphips User Interface program using the Java Swing Library. The program is to display a window that has three buttons and one text field for input and four output fields (you can make these labels or text fields).

The first button is to display a dialog box when pressed. The dialog box that contains information about you, the programmer. This should include your name, User ID, and course name. The dialog box should disappear when the OK button is pressed.

The second button is to simulate the flipping of a coin. The result of a coin flip will be either heads or tails. There is a 50-50 chance fo either result. When the second button is pressed, get an integer value from the input text field and list out the result of that many coin flips. The result is to be displayed in two output fields on the window. One output field is to show the number of results that are heads. The other output field is to show the number of results that are tails. For example, if the integer in the input field is 1, the result could be 0 heads and 1 tails. Or if the integer in the input field is 50, the result could be 28 heads and 22 tails.

The third button is to correspond with two more output fields. These two output field are to show a "running total" of the number of heads and tails. This cumulative amount is to be shown as a percent. These output fields could express that of all of the coin flips done, 49.25% were heads and 50.75% were tails. To get this output, your program would need to know the total number of coin flips, the total number that resulted as heads and the total number that resulted as tails. Each time a coin is flipped (by presses of the the second button), this information is to be updated. The third button is to reset the total number of coin flips to zero, total number that resulted as heads to zero and the total number that resulted as tails to zero. The third button is to clear the cumulative percent of heads and tails.

Your window must include some labels that make the use of your program obvious.

This program will also require a 1-2 page write up of the data structures used in the program and the logical division of your program into multiple source code files (i.e. which routines are where). Remember that this write-up is to be written in ASCII format and is to be electronically turned in with your program. The name of this file should be "readme.txt". Also recall that your program will be given to another student to write a critique. Therefore, it is suggested that you do not include your Social Security Number in your program. Instead use your name and your EECS User ID to identify yourself.

Your program must be written in good programming style. This includes (but is not limited to) meaningful identifier names, a file header at the beginning of each source code file, a function header at the beginning of the function, proper use of blank lines and indentation to aide in the reading of your code, explanatory "value-added" in-line comments, etc.

The work you turn in must be 100% your own. You are not allowed to share code with any other person (inside this class or not). You may discuss the project with other persons; however, you may not show any code you write to another person nor may you look at any other person's written code.

You are to submit this project using the EECS Department's UNIX machine's turnin command. The project name for this assignment is mp5. Be sure to submit all source code, header files, make file as well as your program description. Failure to turnin all required pieces will result in a lower grade for the assignment.