CS 340

Machine Problem 5, Fall 2001

Random Numbers

Due: Tuesday, November 13, 2001 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 two text field for input and two 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 work with the two input fields and the two output field. When this button is pressed, the values from the two input fields are to work with a random number generator to produce a single integer output. This output is to be displayed in the first output field and added to the value in the second output field. The values in the input field are to be integer values greater than or equal to one. If the user attempts to put an invalid value (i.e. a negative or non-integer) in either input field, some appropriate action is to be take by your program.

  1. The second input field is to specify the range of integer values created with the random number generator. This range is to be from 1 to value specified in the input field. Initially this field should have the value of 1.

  2. The first input field is to specify the number of random numbers to be created. Initially this field should have the number of 10.

  3. The sum of these random numbers is to placed in the first output field overwriting any value that is already there.

  4. The sum of the random number is to be added to the value in the second output field and displayed in the second output field. This allows for a "running total" to be shown. Initially this field should have the number of 0.

The thrid button is to reset the value in the second output field to 0 when the button is pressed.

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

A makefile is not required. but the program is to be compiled with the command of:

     javac mp5.java
and executed with the command of:
     java mp5

This program will also require a 1-2 page write up of the code structures used in the program. 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 CS 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 CS Department's UNIX machine's turnin command. The project name for this assignment is mp5. Be sure to submit all source code, header files as well as your program description. Failure to turnin all required pieces will result in a lower grade for the assignment.