Create a Random Integer Generator
Due Dates: Note these are modified!!
- For Students registered for M,W,F Lectures: Thursday 10/29/98
- For Students registered for T,Th Lectures: Monday 11/2/98
Notes on the assignment
Since everyone in the class is creating the same program, each student
must take reasonable steps to make sure there assignment is not copied.
Recall that academic dishonesty includes supplying information as well
as receiving information. Towards this end, you are not to have your
assignment readable in your WWW directory (and any subdirectory of your
WWW directory) until the day after the last due date for the assignment
(Friday 10/30/98). Any student who does not follow this will receive
a grade of zero for the assignment.
In order to work on this assignment, you are to use the "Open File" option
in the Netscape browser to view and run your assignment. Remember that
this will only open a file on the physical machine that you are working
with. If you are running Netscape on one of the EECS machines, you can open
any file in your account (not only the ones in your WWW directory). If
you are not running Netscape on one of the EECS machines, you will have
to transfer the file to the machine your are working on before you can
open the file in Netscape. To transfer the file, use either FTP or Fetch.
Another note on academic dishonesty, you should never show your written
code for an assignment to another student. You may discuss ideas related
to the project,
but code must be entirely written on your own. If you and another student
must discuss code, you must discuss an example other than the assignment.
total any number of randomly created integer values. The user will
provide a maximum value. Your program is to take this maximum value and
create a random number from 1 to the maximum value. You are to use the
The random() method return a value between 0.0 and 1.0 when called. You
are to modify this result to get the random integer value. The modification
is done as follows:
- Multiply the result from random() by the maximum value.
- If the integer is zero, redo the above steps until the integer is not zero.
The program must have the following features:
At the top of the page, be sure to include your name and lab section
day and time (this will allow us to return your grade report to you).
There must be a descriptive paragraph explaining the purpose of the
page somewhere above all of the text fields, buttons and selection box.
Also all input field, buttons and the selection box must have some descriptive
text nearby describing the function each one performs.
- A generate button. When clicked by the user, a new random integer will
- A selection box. The maximum value is selected from a selection box that lists commonly
used maximum values plus an option to allow the user to enter any value
wished. The common maximum values that are to be listed in the selection box are:
When the page is initially loaded, the currently selected maximum value must
be 10. The last option in the selection box is for the user to enter their own maximum
value. When the generate button is clicked and the user has
selected the option to enter their own maximum value, the program must display
value. The default value of this dialog box must initially be 5 and then
be whatever was the last value entered by the user in this box.
- An answer text field. This text field will contain the most recently generated random integer. Initially this field should be blank.
- A total text field. This text field will keep the total of the recently generated random
integers. Initially this field is to have the value of zero. Refer to the clear button below for more information.
- A count text field. A text field that counts the number of random integers that have been
total in the previous text field.
Initially this field is to have the value of zero.
Refer to the clear button below for
- A clear button. When this button is clicked, it will return the total
and count text fields to zero.
Make sure your
code is written using good programming style.
This includes the use of comments, indentation, blank lines and meaningful
identifier names. Each function that you write must have comments at the
start explaining the purpose of the function. Also, at the top of your HTML
file must have a comment explaining the purpose of the file including
your name, and lab section day and time. Even though this comment may be very
similar to the description written on the page itself, descriptions in both
locations are required.
For a total of 10 points extra credit, you can add to your page an additional text
field and an check box. The text box is used to allow the user to get the
results of multiple random integers by only clicking the generation button once.
For example, if the multiple roll text box contained the value of 5, the
results of 5 different random integers would be displayed after clicking the
generate button. This means that the answer text field would only contain
the value of the last random integer, but the total and count text fields
would be updated to reflect all 5 random integers.
The check box is used to automatically clear the total and count text fields
each time the generate button is clicked. This way, the total and count
fields only contain information about the last set of integers created.
As always, late assignments will not be accepted.
You must electronically submit your assignment using the
UNIX command turnin. Note that since this assignment does not
have to be in your WWW directory, you will be graded based on what is
turned in. If you do not turn in your assignment correctly, your grade
To electronically hand in your assignment using the UNIX turnin
type one of the following commands depending on which lecture your
are registered, where FILELIST is the names of all of the
files you are submitting.
- For Students registered for M,W,F Lectures type:
turnin -ceecs101 -pmp4a FILELIST
- For Students registered for T,Th Lectures type:
turnin -ceecs101 -pmp4b FILELIST
Department of Electrical Engineering and Computer Science
University of Illinois at Chicago