Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create an application interface as shown below that calculates not only the miles per gallon, but also the average miles per gallon. 1. Open the

create an application interface as shown below that calculates not only the miles per gallon, but also the average miles per gallon.

image text in transcribed

1. Open the respective html, CSS files given in this assignment and build upon the structure by writing an internal Javascript code to make the above interface work.

2. Declare two global variables named totalMiles and totalGallons and assign them starting values of zero.

(Like this, right after you add the "use strict" directive: var totalMiles = 0, totalGallons = 0;)

3. For each valid user entry, add the miles to the totalMiles variable and add the gallons to the totalGallons variable.

4. Calculate the average miles per gallon using the CalculateMPG function, and store the result in the text box with avg_mpg as its id.

------------------

html code:

Calculate MPG

var $ = function (id) {

return document.getElementById(id);

}

var calculateMPG = function(miles, gallons) {

}

var processEntries = function () {

var miles = parseFloat($("miles").value);

var gallons = parseInt($("gallons").value);

}

}

window.onload = function () {

}

Calculate Miles Per Gallon

Css File:

body {

font-family: Arial, Helvetica, sans-serif;

background-color: white;

width: 450px;

margin: 0 auto;

padding: 0 2em 1em;

border: 3px solid blue;

}

h1 {

color: blue;

margin-bottom: .25em;

}

label {

float: left;

width: 11em;

text-align: right;

}

input {

margin-left: 1em;

margin-bottom: .5em;

margin-right: .5em;

width: 11em;

}

span {

color: red;

}

Calculate Miles Per Gallon Miles Driven: 372.4 Gallons of Gas Used: 13.7 Miles Per Gallon 28.6 Avg. Miles Per Gallon 29.4 Calculate MPG

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions

Question

What are the health and safety conditions?

Answered: 1 week ago

Question

Choose the best eption for the preeursor to eyelotetradecyne

Answered: 1 week ago