We want to be able to have JavaScript generate HTML items. In this program, when a button is clicked a function is called that generates an html table of miles per hour values and their equivalent kilometers per hour values on the page. The table should be inserted in an HTML divison. Use the array of mph values given below. You cannot modify this array. The kph values should be rounded to 1 decimal place. var mph = [20, 35, 45, 55, 65, 70, 75, 80, 90]; The HTML table must be generated using a JavaScript loop and the array give above. The table is displayed only after a button is pressed. Examples of this kind of thing are given in the Lecture notes for the week discussing loops and arrays. Once the button is clicked, the table on the page should look like the following (more or less, the exact style is not important), with the list of 9 mph values given on the left, and all 9 equivalent kph values displayed in the right column. You may style your table, or leave it very plain-- either way is OK. Miles per Hr. Kilometers per Hr. 20 35 45 55 65 70 75 80 90 32.2 56.3 72.4 88.5 104.6 ...and so on... ...and so on... ...and so on... ...and so on... The formula that converts from mph to kph is given here: kph = mph * 1.609 Round your conversions to 1 decimal place. Use the toFixed() method.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Hello, I am in need of some assistance on an assignment, & would like some guidance as to what I should do!

It's a simple JavaScript program, I wish to create a HTML table, using proper tags for table, rows, & data, to make a conversion between MPH to KPH with a single press of a button.

 

The two images show the data for the loops & arrays, & what the intended outcome is, I am just unsure of how to create the table & have it display the conversion via a button click.

We want to be able to have JavaScript generate HTML items. In this program, when a button is clicked, a function is called that generates an HTML table of miles per hour values and their equivalent kilometers per hour values on the page. **The table should be inserted in an HTML division.** Use the array of mph values given below. You cannot modify this array. The kph values should be rounded to 1 decimal place.

```javascript
var mph = [20, 35, 45, 55, 65, 70, 75, 80, 90];
```

The HTML table must be generated using a JavaScript loop and the array given above. The table is displayed only after a button is pressed. Examples of this kind of thing are given in the Lecture notes for the week discussing loops and arrays.

Once the button is clicked, the table on the page should look like the following (more or less, the exact style is not important), with the list of 9 mph values given on the left, and all 9 equivalent kph values displayed in the right column. You may style your table, or leave it very plain--either way is OK.

```
Miles per Hr.  |  Kilometers per Hr.
-------------------------------------
20             |  32.2
35             |  56.3
45             |  72.4
55             |  88.5
65             |  104.6
70             |  ...and so on...
75             |  ...and so on...
80             |  ...and so on...
90             |  ...and so on...
-------------------------------------
```

The formula that converts from mph to kph is given here:  **kph = mph * 1.609**

Round your conversions to 1 decimal place. Use the `toFixed()` method.
Transcribed Image Text:We want to be able to have JavaScript generate HTML items. In this program, when a button is clicked, a function is called that generates an HTML table of miles per hour values and their equivalent kilometers per hour values on the page. **The table should be inserted in an HTML division.** Use the array of mph values given below. You cannot modify this array. The kph values should be rounded to 1 decimal place. ```javascript var mph = [20, 35, 45, 55, 65, 70, 75, 80, 90]; ``` The HTML table must be generated using a JavaScript loop and the array given above. The table is displayed only after a button is pressed. Examples of this kind of thing are given in the Lecture notes for the week discussing loops and arrays. Once the button is clicked, the table on the page should look like the following (more or less, the exact style is not important), with the list of 9 mph values given on the left, and all 9 equivalent kph values displayed in the right column. You may style your table, or leave it very plain--either way is OK. ``` Miles per Hr. | Kilometers per Hr. ------------------------------------- 20 | 32.2 35 | 56.3 45 | 72.4 55 | 88.5 65 | 104.6 70 | ...and so on... 75 | ...and so on... 80 | ...and so on... 90 | ...and so on... ------------------------------------- ``` The formula that converts from mph to kph is given here: **kph = mph * 1.609** Round your conversions to 1 decimal place. Use the `toFixed()` method.
**MPH to KPH Conversion Tool**

This educational tool is designed to help users understand the conversion between Miles per Hour (MPH) and Kilometers per Hour (KPH).

**Interface Description:**

- **Before Click:**
  - A simple interface labeled "MPH to KPH" with a button labeled "Display Data."

- **After Click:**
  - The interface expands to display a conversion table. This table lists speeds in MPH alongside their equivalent speeds in KPH.

**Conversion Table:**

| Miles per Hour | Kilometers per Hour |
|----------------|----------------------|
| 20             | 32.2                 |
| 35             | 56.3                 |
| 45             | 72.4                 |
| 55             | 88.5                 |
| 65             | 104.6                |
| 70             | 112.7                |
| 75             | 120.7                |
| 80             | 128.7                |
| 90             | 144.8                |

This tool provides a quick reference for understanding how speeds in the commonly used unit of miles per hour convert to kilometers per hour, a metric unit often used globally.
Transcribed Image Text:**MPH to KPH Conversion Tool** This educational tool is designed to help users understand the conversion between Miles per Hour (MPH) and Kilometers per Hour (KPH). **Interface Description:** - **Before Click:** - A simple interface labeled "MPH to KPH" with a button labeled "Display Data." - **After Click:** - The interface expands to display a conversion table. This table lists speeds in MPH alongside their equivalent speeds in KPH. **Conversion Table:** | Miles per Hour | Kilometers per Hour | |----------------|----------------------| | 20 | 32.2 | | 35 | 56.3 | | 45 | 72.4 | | 55 | 88.5 | | 65 | 104.6 | | 70 | 112.7 | | 75 | 120.7 | | 80 | 128.7 | | 90 | 144.8 | This tool provides a quick reference for understanding how speeds in the commonly used unit of miles per hour convert to kilometers per hour, a metric unit often used globally.
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education