[an error occurred while processing this directive]
File: part2.shtml
Creator: George Ferguson
Created: Thu Sep 27 09:38:29 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]
CSC170: Introduction to Programming and the Web Fall 2012
[an error occurred while processing this directive]
Assignment 5: Iteration
[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]
Building on the example from Question 3 of Part 1,
this time we will process all the students in the class, not
just one. So create a page that helps with grading as follows:
Ask the user for the name of a student. If there are no more
students to enter, the user can enter "stop".
As before, ask the user for that student's grades on the
assignments one at a time, entering -1 to stop entering
grades for that student.
Display the collected grades, number of grades, and average
grade for each student as well as the class average, using a
table. Since each student may have different numbers of
grades, you can display all the individual grades in one table
cell. That is, your columns are (probably) name, grades,
number of grades, and average grade.
Things to think about
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?
[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: Monday, 01-Oct-2012 19:05:13 EDT
[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]