Create a Random Integer Generator

Due Dates: Note these are modified!!

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.

The Assignment

You are to write a JavaScript program that allows a user to create and 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 JavaScript method random() of the Math object.

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:

  1. Multiply the result from random() by the maximum value.
  2. Use the JavaScript ceiling function to convert this to an integer.
  3. 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.

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 will suffer. 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.
 Department of Electrical Engineering and Computer Science
 University of Illinois at Chicago