[an error occurred while processing this directive]
File: index.shtml
Creator: George Ferguson
Created: Thu Sep 27 09:23:28 2012
Time-stamp:
[an error occurred while processing this directive]
File: templates/doc-start.shtml
Creator: George Ferguson
Created: Tue Dec 6 12:31:29 2011
Time-stamp:
[an error occurred while processing this directive]
File: site-settings.shtml
Creator: George Ferguson
Created: Tue Dec 6 13:49:49 2011
Time-stamp:
Site (or subsite)-wide settings.
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
File: head.shtml
Creator: George Ferguson
Created: Tue Dec 6 12:34:15 2011
Time-stamp:
SSI variables for this template:
head_title if given, else ``sitename | title''
[an error occurred while processing this directive]
File: head-title.shtml
Creator: George Ferguson
Created: Tue Dec 6 14:29:52 2011
Time-stamp:
SSI variables for this template:
head_title: complete content of title element if given
site_title trailing part of title (if given)
section_title middle part of title (if given)
page_title leading part of title (if given)
title title shown on page, also used as leading part of title (if given)
[an error occurred while processing this directive]
(none)
[an error occurred while processing this directive]
File: head-meta.shtml
Creator: George Ferguson
Created: Tue Dec 6 14:29:18 2011
Time-stamp:
SSI variables for this template:
meta_description
meta_keywords
meta_generator
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
File: head-stylesheets.shtml
Creator: George Ferguson
Created: Tue Dec 6 14:22:58 2011
Time-stamp:
SSI variables for this template:
site_stylesheet, page_stylesheet
stylesheet0, stylesheet1, ...: URL for stylesheets
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
File: head-scripts.shtml
Creator: George Ferguson
Created: Tue Dec 6 14:23:19 2011
Time-stamp:
SSI variables for this template:
site_script, page_script
script0, script1, ...: URLs of javascript scripts
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]
File: body-start.shtml
Creator: George Ferguson
Created: Tue Dec 6 13:20:46 2011
Time-stamp:
SSI variables for this template:
body_class
page_class
page_id
[an error occurred while processing this directive]
[an error occurred while processing this directive]
File: body-header.shtml
Creator: George Ferguson
Created: Tue Dec 6 13:46:12 2011
Time-stamp:
Content above banner, if any.
[an error occurred while processing this directive]
File: body-title.shtml
Creator: George Ferguson
Created: Tue Dec 6 14:34:49 2011
Time-stamp:
SSI variables for this template:
section_name First line of title on page (if any)
title Title shown on page
[an error occurred while processing this directive]
DMS102/CSC170D: Introduction to Web Development Spring 2013
[an error occurred while processing this directive]
Assignment 5: Iteration
[2 pts]
Create a page that displays the square of each of the first ten
integers starting at 1 using a table.
[2 pts]
Create a page that asks the user for a number and then displays
the square of the ten numbers starting with that one, using a table.
[2 pts]
Create a page that uses a for loop to demonstrate
each of the six possible HTML heading types
(h1..h6).
[2 pts]
Create a page that asks the user for a number n and then
uses a for loop to compute the value of n!
(the factorial
function). I'll save you the trouble of looking it up: n!
is the product of all the numbers from 1 up to and including n.
[2 pts]
Create a page that asks the user for a year (number) and displays
whether or not it is a leap year. Use only one if statement
with a Boolean expression to do the test. The definition of a leap
year is a year that is evenly divisible by 4, but not evenly
divisible by 100, unless also evenly divisible by 400.
[4 pts]
Create a page that helps with grading as follows:
Ask the user for the name of a student. If there are no more
students, the user can enter "stop". (Make this clear in your
prompt.)
For that student, ask the user to enter the student's grades
one at a time. If there are no more grades, the user can enter
"stop".
Display the following as a row in a table:
The student's average grade
The student's maximum grade
The student's minimum grade
Make sure your table has informative column headers, and
feel free to style the table to look better if you like.
Repeat until the user enters "stop" for a student name. (Think
about how you need to structure your loops to achieve this.)
Note: Think about how/when you need to start and end your table.
Things to think about
Iteration allows you to repeat a statement or block. Combined
with conditionals, you can do different things each time around
the loop.
It is crucial that the body of a loop change something that
(eventually) changes the value of the loop condition from true to
false, otherwise the loop will never stop. See what happens when
your browser executes a script with an infinite loop (hint: it
ain't pretty).
There are many ways to write iterative programs:
The book describes counter-controlled and sentinel-controlled
loops, which are different ways of deciding when to end the
iteration;
while, for,
and do-while loops, which are
different control statements for formulating your iteration in
Javascript.
Deciding how to express your algorithm using the various control
constructs is part of the art of programming. But you should be
familiar with all the tools in the toolkit so you can make the
right choices when designing your program.
Iteration control constructs can be nested, just like HTML
elements and conditionals. Makes you think that nesting (embedding)
is kind of an important concept, no?
Iteration is particularly nice for generating tables in web pages,
no?
[an error occurred while processing this directive]
File: doc-finish.shtml
Creator: George Ferguson
Created: Tue Dec 6 13:46:48 2011
Time-stamp:
[an error occurred while processing this directive]
File: body-footer.shtml
Creator: George Ferguson
Created: Tue Dec 6 14:43:56 2011
Time-stamp:
Content at bottom of page, if any.
Last update: Thursday, 07-Feb-2013 11:08:24 EST
[an error occurred while processing this directive]
File: body-finish.shtml
Creator: George Ferguson
Created: Tue Dec 6 13:47:36 2011
Time-stamp:
[an error occurred while processing this directive]