3
CIS 275 Web Programming I
Sections 1 and 2 (Tulloss), Fall 2001
Assignment 4 – Textbook Chapters 1 through 4 Material
PURPOSE
The purpose of this lab is to:
· Help reinforce material contained in chapters (tutorials) 1 through 4 in your textbook.
· Give you a bit of a break.
DIRECTIONS
- Create an HTML document called Array4.htm that creates and prints an array containing various types of information (Tutorial 3, Section A).
- The array should include
- A whole number e.g. 5.
- A floating-point number e.g. 3.5.
- A text string e.g. your name.
- A boolean (true/false) value.
- A null value.
- Output should follow this general format for each element in the array:
- A description e.g. “Whole Number”
- A <Tab> escape sequence (\t)
- The array element e.g. myArray[0]
- A newline escape sequence (\n)
- Example: document.write(“Whole number:\t” + myArray[0] +”\n”);
- Make sure your <SCRIPT> is enclosed in the <PRE> and </PRE> tags.
- Create an HTML document called CarpetCost4.htm that calculates the square feet of carpet required to carpet a room (Tutorial 3, Section B).
- Include three text boxes.
- Create one text box for the width of the room in linear feet.
- Create one text box for the length of the room in linear feet.
- Create one text box for the cost per square foot of carpet.
- When you calculate the cost, add 25% to the total number of square feet to account for closets and other features of the room.
- Display the total cost in an alert dialog box.
- Save this file as CarpetCost4.htm.
- Create an HTML document called ConvertTemp4.htm that converts Fahrenheit to Celsius and Celsius to Fahrenheit (Tutorial 3, Section B).
- The formulas:
- F to C: Subtract 32 from the Fahrenheit temp, and then multiply the remainder by 0.55.
- C to F: Multiply the Celsius temp by 1.8, and then add 32.
- The exact implementation is up to you. One possible implementation might include:
- Two text boxes: one for F and one for C.
- Two buttons: one that converts from F to C, and another that converts C to F.
- Create an HTML document called Switch4.htm (Tutorial 4, Section A).
- Use the prompt() method to accept input from the user asking for the name of a sport and store the value in a variable named sport.
- Rewrite the following code using a switch statement to tell the user what type of playing field is used in that sport.
if (sport == “golf”)
alert(“Golf is played on a golf course.”);
else if (sport == “tennis”)
alert(“Tennis is played on a tennis court.”);
else if (sport == “baseball”)
alert(“Baseball is played on a baseball diamond.”);
else if (sport == “basketball”)
alert(“Basketball is played on a basketball court.”);
else
alert(“I’m not sure what kind of field ” + sport + “ is played on.”);
- Create an HTML document called IfElse.htm (Tutorial 4, Section A).
- Use the prompt() method to accept input from the user asking for the last name of their favorite NFL quarterback and store the value in a variable named qb.
- Rewrite the following code using an if...else statement to tell the user who the quarterback plays for.
switch (qb) {
case “Favre”:
alert(qb + “ plays for Green Bay”);
break;
case “Culpepper”:
alert(qb + “ plays for Minnesota”);
break;
case “McNair”:
alert(qb + “ plays for Tennessee”);
break;
case “Manning”:
alert(qb + “ plays for Indianapolis”);
break;
case “Warner”:
alert(qb + “ plays for St. Louis”);
break;
default:
alert(“I’m not sure who “ + qb + “ plays for.”);
NOTES
· Don’t forget the identification block in each of your files (name, class, section, etc).
· You may use resources available on my Web site. For example, you may want to use the HTML_template.htm file that I’ve provided in class.
DUE DATE
This assignment is due no later than Friday, 5 October at the start of class. Submit your files to me in an envelope that’s labeled with:
· Your name
· Class and section
· Assignment number
· Due date
The envelope should contain:
· Your program files on disk.
· A hardcopy of the code for each of your files.
Page 3 of 3