Menu

(Solved) : Create Webpage Uses Javascript Calculate Car S Gas Mileage Formula Calculating Miles Car T Q33298671 . . .

Create a webpage that uses JavaScript to calculate a cars gas mileage. The formula for calculating the miles that a car can travel per gallon of gas is: MPG Miles Gallons In the formula, MPG is miles-per-gallon, miles is the mumber of miles that can be driven on a full tank ofgas, and gallons is the mumber of gallons that the tank holds The webpage should use an HTML HTML5 form with textbox input elements and two button elements...one to initiate calculation (calling a function to calculate MPG) and display output and the other button to call a function to clear the textboxes and set the focus on the first textbox. What should JavaSeriptapplicatipn do? 1. A form should be used with all appropriate elements (form, label, fieldset, etc.) and attributes (action, for, name, id, value, etc.) 2. Consider using CSS for background color, form layout, font elements...make use of CSS. You might want to use a table also for lavot but CSS is better. 3. When the page loads, the focus should be set to the first textbox. Consider using the autofocus attribute. This attribute specifies that the input field should automatically get tocus. ID your mput elements. 4. The user should be able to enter the number of gallons of gas the tank holds, and the number ofmiles the car can be driven on a full tank ***consider reguired field input by usev. Use the reguired attribute to spscify that an inputfisld must befilled out before submitting ths form 5. When the Calculate 1 G button is clicked a function named G C R ⓓ should be called that will retrieve the values from the textboxes eallons and number of miles and convert them into actual umbers, since they come from textboxes and then should calculate the Miles per Gallon according to the above formula. NOTE: Textboxes hold strings. To use values in textboxes to do math calculations, they must be converted from strings into numbers. The parseFloat) function parses/converts a string and returns a floating point numbes. For example, parsaFloat 10.33) converts the string 10.33 into an actual number 10.33 that can be used in calculation. 6. Make sure to use proper JavaScript syntax and make sure to declare necessary variables to store values and convert the values into numbers that can be used in an arithmetic 7. Finally, the script should display into a READ-ONLY textbox the number of miles that the car can be driven per gallon of gas (miles per gallon). **Use the eadanb attributs to specif that the irputfield is read only (carot be chagsd* 8. All JavaScript code the two functions hat will do page and placed at the end. he calculation and clearm of tex boxes should be placed inside the head> head» element or msde he body of your 9. The form should also have a Clear button that when clicked on will call a function named clearAllO that clears all textboxes and sets the focus on the first textbox. The webpageapplications interface should appear similarto the below figure, but much better. Gallons of gas the car can hold Number of miles it can be driven on full tank Miles per galion Calculate MPG Clear

Create a webpage that uses JavaScript to calculate a car’s gas mileage. The formula for calculating the miles that a car can travel per gallon of gas is: MPG Miles Gallons In the formula, MPG is miles-per-gallon, miles is the mumber of miles that can be driven on a full tank ofgas, and gallons is the mumber of gallons that the tank holds The webpage should use an HTML HTML5 form with textbox input elements and two button elements…one to initiate calculation (calling a function to calculate MPG) and display output and the other button to call a function to clear the textboxes and set the focus on the first textbox. What should JavaSeript’applicatipn do? 1. A form should be used with all appropriate elements (form, label, fieldset, etc.) and attributes (action, for, name, id, value, etc.) 2. Consider using CSS for background color, form layout, font elements…make use of CSS. You might want to use a table also for lavot but CSS is better. 3. When the page loads, the focus should be set to the first textbox. Consider using the autofocus attribute. This attribute specifies that the input field should automatically get tocus. ID your mput elements. 4. The user should be able to enter the number of gallons of gas the tank holds, and the number ofmiles the car can be driven on a full tank ***consider reguired field input by usev. Use the reguired attribute to spscify that an inputfisld must befilled out before submitting ths form 5. When the Calculate 1 G button is clicked a function named G C R ⓓ should be called that will retrieve the values from the textboxes eallons and number of miles and convert them into actual umbers, since they come from textboxes and then should calculate the Miles per Gallon according to the above formula. NOTE: Textboxes hold strings. To use values in textboxes to do math calculations, they must be converted from strings into numbers. The parseFloat) function parses/converts a string and returns a floating point numbes. For example, parsaFloat 10.33″) converts the string “10.33” into an actual number 10.33 that can be used in calculation. 6. Make sure to use proper JavaScript syntax and make sure to declare necessary variables to store values and convert the values into numbers that can be used in an arithmetic 7. Finally, the script should display into a READ-ONLY textbox the number of miles that the car can be driven per gallon of gas (miles per gallon). **Use the eadanb attributs to specif that the irputfield is read only (carot be chagsd* 8. All JavaScript code the two functions hat will do page and placed at the end. he calculation and clearm of tex boxes should be placed inside the head> head» element or msde he body of your 9. The form should also have a Clear button that when clicked on will call a function named clearAllO that clears all textboxes and sets the focus on the first textbox. The webpage’application’s interface should appear similarto the below figure, but much better. Gallons of gas the car can hold Number of miles it can be driven on full tank Miles per galion Calculate MPG Clear Show transcribed image text

Expert Answer


Answer to Create Webpage Uses Javascript Calculate Car S Gas Mileage Formula Calculating Miles Car T Q33298671 . . .

OR