CSD 340: The Week beginning Feb. 7
We will have a test next week. We will discuss which day.
- Reading:
Review Chapters 2 and 3 in Beginning JavaScript
- Homework:
Write a page that has the user enter two numbers and then display the sum of the numbers
in that range. See the screen captures below.
Hey wait, that's not summation, that's concatenation. You can use the parseInt() method
(discussed on page 45 of Beginning JavaScript (Paul Wilton) to resolve this problem.
Here's a picture of Gauss to include on the page.
Due Feb. 14
- Monday:
- Ratings Page. Write a page that has the user enter a rating (a number between 1 and 10) and
then displays that number of stars.
- Declare a Rating variable and use the prompt method to have the user input a number which will be
assigned to it.
- Declare a variable to hold some HTML code. Assign to it the code to display some text and
append their rating. (Mine was in <h1> tags and used gold colored font.)
- Have a loop that repeatedly appends to your HTML variable the HTML code to display the
star image. You will probably have to use either the height or width
attribute of the <img> tag to control its size.
- Write the HTML code to the document.
- Jiri Kolar Inspired Page. Write a page that displays alternating slices of
two images.
- Declare a variable to hold some HTML code. Assign to it a blank space " " or
possibly a <center> tag.
- Have a loop that repeatedly appends the HTML code to display the first slice of
your first image followed by the first slice of your second image.
(PossibleSlicesZipped.zip)
- (If you started with a center tag, close it after the loop.)
- Write the HTML code to the document.
- Suppose you have an image name such as VenusSlice1.jpg, break the code up and use
concatenation so that the 1 can be replaced with your loop's counting variable.
- Wednesday:
Write a page that allows the user to choose the number of times that a single die
will be rolled.
Declare six variables, the first will keep track of the number of times a 1 is rolled;
the second will keep track of the number of times a 2 is rolled; and so on. In a loop
(with the number of iterations determined by the user) simulate a single die roll, if
the result is a 1, increment the first variable; if the result is a 2, increment the
second variable; and so on. Then display the results as shown in the screen capture
below.
(This code can be more efficiently written using an array, but we haven't learned
that yet.) Either post the code and send me the link or send me the HTML file.
- Friday:
The switch and while structures uses
TablesInTables2.htm,
WaitingforSnakeEyes.htm
and
Snake2.gif.