|
Objectives:
· Introduce the basic of JavaScript’s elements and functions embedded in HTML
· Introduce developer tools and web console in browser
Note: Before you start the lab, run template.html and test the Pizza Calculator and see how it works. You will use similar form and function to create a Gas Mileage calculator
Tasks
1. Write out the contents of an HTML file gas.html that would run a JavaScript script containing a form with fields that allow the user to enter a starting odometer reading, and ending odometer reading, and the number of gallons of gas consumed during that trip. Include a button that is labeled "calculate gas mileage". That button should invoke a JavaScript function that performs the calculation.
The formula is:
|
gas mileage =
|
(endOdometer - startOdometer)
|
|
|
totalGallons
|
Your input will be 3 values:
1- StartOdometer
2- EndOdometer
3- TotalGallons
4- You will implement the above simple formula which takes the difference between end of an odometer reading and start of odometer reading and divide them by the a number of gallons of gas, no need to use for Math.PI as in the template
Your output will be Gas mileage
Note: Use the template.html as a basis for your form and JavaScript
What to Submit:
1- Snapshots of your working form that show the results
2- Upload them to D2L drop box.
|