Write an HTML web page with a textbox, a button and an image
that initially displays blank.jpg. When a number from 1 to 6 is entered
into the textbox and the button is clicked,
the page should display the corresponding image of a dog
with its owner:
The builtin-in random number generator Math.random returns
floating point numbers in the interval [0,1). This means
that it can return 0 but it cannot return 1.
We want to write a JavaScript expression that returns
random integers {1, 2, 3, 4, 5, 6} with equal probability.
We use Math.random and Math.floor together to accomplish this:
Math.random( ) returns a floating point in [0, 1).
6 * Math.random( ) returns a floating point in [0, 6).
Math.floor(6 * Math.random( )) returns an integer in
{0, 1, 2, 3, 4, 5}.
1 + Math.floor(6 * Math.random( )) returns an integer in
{1, 2, 3, 4, 5, 6}.
Use the following JavaScript statement to get a simulated roll of
a fair die:
Normally you should not access images on someone elses
website; multiple hits on their site will tie up their server.
Place images on your site instead.
For Project Proj5, you have permission to access the lotto
balls on Jost's website. Here is a link to the lotto balls folder:
Normally you should not access images on someone elses
website; multiple hits on their site will tie up their server.
Place images on your site instead.
However, for Project Proj5, you have permission to access the lotto
balls on Jost's website. Here is a link to the lotto balls folder: