CS 1 - Lab 7

Outcomes:

Upon completion of the lab, the student will know how to:

1.

For this lab you will use while loops to implement two lottery applications

  • Create an HTML file for this lab assignment called lab7.html (See the instructions for Lab 2 if you are unsure how to do this.)
  • Download the random.js file here if you don't already have it from last week's lab
  • In order to use the functions in the random.js library you will need a script tag with the src attribute set to random.js

2.

First you will be writing an application that simulates a PICK-4 lottery.

  • Your application will repeatedly simulate a PICK-4 lottery drawing until a specific sequence is obtained.
  • The user should be able to enter the desired sequence in a series of four text boxes.
  • The user then clicks a button to see how many drawings had to be done before the sequence was picked.
  • The results (the number of drawings) should then be displayed in a text box.
  • Each drawing should consist of 4 random numbers between 0 and 9.
  • Numbers can be repeated, so 0-0-0-0, 3-7-5-3, and 4-0-9-4 are all legitimate sequences.
  • You must use a while loop for this part of the lab.

3.

Next you will write an application to perform a specific number of PICK-4 drawings.

  • Add a text field that will be used to store the number of drawings the user wishes to perform
  • Add a button that the user will click to do the drawings
  • Add a text area where the results of each drawing are displayed.
  • You may use a while loop or a for loop for this part of the lab.

4.

When you are done, upload the lab7.html file to the CS server using FileZilla. (See the instructions for Lab 1 if you are unsure how to do this)