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

  1. Create an HTML document called Array4.htm that creates and prints an array containing various types of information (Tutorial 3, Section A).
  2. The array should include
  3. A whole number e.g. 5.
  4. A floating-point number e.g. 3.5.
  5. A text string e.g. your name.
  6. A boolean (true/false) value.
  7. A null value.
  8. Output should follow this general format for each element in the array:
  9. A description e.g. “Whole Number”
  10. A <Tab> escape sequence (\t)
  11. The array element e.g. myArray[0]
  12. A newline escape sequence (\n)
  13. Example: document.write(“Whole number:\t” + myArray[0] +”\n”);
  14. Make sure your <SCRIPT> is enclosed in the <PRE> and </PRE> tags.
  1. Create an HTML document called CarpetCost4.htm that calculates the square feet of carpet required to carpet a room (Tutorial 3, Section B).
  2. Include three text boxes.
  3. Create one text box for the width of the room in linear feet.
  4. Create one text box for the length of the room in linear feet.
  5. Create one text box for the cost per square foot of carpet.
  6. When you calculate the cost, add 25% to the total number of square feet to account for closets and other features of the room.
  7. Display the total cost in an alert dialog box.
  8. Save this file as CarpetCost4.htm.

  1. Create an HTML document called ConvertTemp4.htm that converts Fahrenheit to Celsius and Celsius to Fahrenheit (Tutorial 3, Section B).
  2. The formulas:
  3. F to C: Subtract 32 from the Fahrenheit temp, and then multiply the remainder by 0.55.
  4. C to F: Multiply the Celsius temp by 1.8, and then add 32.
  5. The exact implementation is up to you. One possible implementation might include:
  6. Two text boxes: one for F and one for C.
  7. Two buttons: one that converts from F to C, and another that converts C to F.
  1. Create an HTML document called Switch4.htm (Tutorial 4, Section A).
  2. 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.
  3. 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.”);

  1. Create an HTML document called IfElse.htm (Tutorial 4, Section A).
  2. 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.
  3. 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