Lab5:Conditional Programming

The objective for today's lab is to investigate Conditional programming.

This program prompts the user for a length and width of the house and then computes the perimeter of the house

  1. Create a web page with
    1. 3 text boxes: length, width, and perimeter
    2. a button - "Go!"
    3. div tags with ids that will be used to display the Error messages if an invalid value is entered
  2. Create a Javascript function that accepts and validates the length and width of the house
    • Use conditionals to verify the width and if invalid:
      place an appropriate error message in the innerHTML of the corresponding div tag
      Have the error message be in ref font
      and do not calculate the perimeter
    • They both need to be numbers
    • House length cannot be less than 24
    • House length cannot be bigger than 75
    • House width cannot be less than 36
    • House width cannot be bigger than 100
  3. Calculate the perimeter: 2*(length_of_house+width_of_house)