I was wondering if I could get help on this project.
there were a couple answers regarding this project in answers, but
they did not do exactly what the directions asked for the project.
I attached the html code for the project. I think it calls for all
the code to be done on its own javascript file, not in the html
code.
Hands-On Project 2-1
In this project you will create an application to convert
temperature readings between Fahrenheit and Celsius and between
Celsius and Fahrenheit. The formula to convert a Fahrenheit
temperature to the Celsius scale is
Celsius = (Fahrenheit − 32)/1.8
and the formula to convert a Celsius temperature to the
Fahrenheit scale is
Fahrenheit = Celsius × 1.8 +
32
Users will enter a value in a Celsius or Fahrenheit input box,
press the Tab key and have the other input box automatically show
the temperature reading in the other scale. A preview of the
completed page is shown in Figure 2-30.
Figure 2-30
Completed Project 2-1
Do the following:
Use your code editor to open
the project02-01_txt.html and project02-01_txt.js files
from the js02 ► project01 folder. Enter your name and the date in
the comment section of each file and save them
as project02-01.html and project02-01.js,
respectively.
Go to the project02-01.html file in
your code editor and in the head section add
a script element to load the project02-01.js file.
Include the defer attribute to defer loading the external
script file until the entire page is loaded. Study the contents of
the HTML file and then save your changes.
Go to the project02-01.js file in
your code editor. Create a function
named FahrenheitToCelsius() containing a single parameter
named degree. Insert a statement that returns the value
of degree minus 32 and then divided by 1.8.
Create a function
named CelsiusToFahrenheit() containing a single parameter
named degree. Insert a statement that returns the value
of degree multiplied by 1.8 plus 32.
Add an onchange event handler to the element with the
id “cValue”. Attach an anonymous function to the event handler and
within the anonymous function do the following:
Declare a variable named cDegree equal to the value of
the element with the id “cValue”.
Set the value of the element with the id “fValue” to the value
returned by the CelsiusToFarenheit() function
using cDegree as the parameter value.
Add an onchange event handler to the element with the
id “fValue”. Attach an anonymous function to the event handler and
within the anonymous function do the following:
Declare a variable named fDegree equal to the value of
the element with the id “fValue”.
Set the value of the element with the id “cValue” to the value
returned by the FarenheitToCelsius() function
using fDegree as the parameter value.
Save your changes to the file.
Open project02-01.html in your web
browser. Verify that when you
enter 45 in the Temp in box
and press Tab a value of 113 appears in the Temp in box.
Verify that when you enter 59 in the
Temp in box and press Tab a value of 15 appears in the
Temp in box.
<!DOCTYPE html>
<html>
<head>
<!--
JavaScript 7th Edition
Chapter 2
Hands-on Project 2-1
Author:
Date:
Filename: index.htm
-->
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width,initial-scale=1.0">
<title>Hands-on Project 2-1</title>
<link rel="stylesheet" href="styles.css"
/>
<script src="js02-01.js"
defer></script>
</head>
<body>
<header>
<h1>Hands-on Project
2-1</h1>
</header>
<article>
<h2>Fahrenheit (° F) to Celsius
(° C) converter</h2>
<form>
<div>
<h3>Temp in
° F</h3>
<input type="number"
id="fValue" value="32" />
</div>
<div
id="arrow">↔</div>
<div>
<h3>Temp in
° C</h3>
<input type="number"
id="cValue" value="0" />
</div>
</form>
<footer>
Enter a Fahrenheit or Celsius
temperature in either input box and press Tab to convert.
</footer>
</article>
</body>
</html>
/* JavaScript 7th Edition
Chapter 2
Project 02-01
Celsius <-> Farenheit Coverter
Author:
Date:
Filename: project02-01.js
*/
I was wondering if I could get help on this project. there were a couple answers regarding this project in answers, but th
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am