IT581: Practicum in Web Development, Summer 2015 (Hybrid)

Lab Exercise 12: Feel the burn! Calculations

Due at the endo of class session on July 27. You may have 24 hours extension.

Use the Firefox or Mozilla browser and open the JavaScript or Error console. Clear the console messages if necessary.

The problem

A person can lose 1 pound of weight for each 3500 calories burned through exercise. So

  total weight lost = total calories burned / 3500

A person burns 200 calories per hour by bicycling. The number of calories burned by an activity is given by

 calories burned by activity = hourly rate for activity * number of hours

For this lab, you will make a page that lets a person find out how much weight they lose through bicycling.

Your first task - create a program

First write a JavaScript program that will calculate weight lost by bicycling:

Use the Test Area.

  1. Use the prompt method to ask the user for the number of hours spent at bicycling.
    Don't forget to make it a number with parseFloat.
  2. Calculate and report, using the alert method, the number of calories burned by bicycling
  3. Calculate and report, using the alert method, the pounds worked off by bicycling

Test your program in the test area. (Try: if you enter 70 hours, the results should be 14000 calories burned and 4 pounds lost.)

Your second task - create a page

Incorporate your program into an HTML page.

You can start the basic blank HTML document. Give it an appropriate title and heading.

Use document.write instead of alert for the output.

Your third task - personalize the page

Put another script section in the page:

A nice extra touch would be to use the person's name in the prompt for the number of hours.

Upload to wyrd server and submit the wyrd link using Blackboard

Comments to: dong@hood.edu
Last Modified: 27 July 2015. 19:57