Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Filename: index.htm Hands-on Project 2-1 Hands-on Project 2-1 Fahrenheit ( F) to Celsius ( C) converter Enter temp in &176; F Convert to C Temp

image text in transcribed
image text in transcribed
Filename: index.htm Hands-on Project 2-1
Hands-on Project 2-1

Fahrenheit ( F) to Celsius ( C) converter

Temp in Cs/p>

c/articles 1 2 3. In your text editor, open index.htm from the HandsOn Project2-1 folder in the Chapter02 folder. Enter your name and today's date where indicated in the comment section in the document head. At the bottom of the document, before the closing

tag, enter insert a blank line, and then enter to create a new script section Within the script section you created in the previous step, enter the following function. function convert var degF - document.getElementById("Value").values war deg degr - 3259; document.getElementById("Value").innerHTML degC) 3 3 This function, named convert 1), starts by looking up the Fahrenheit value entered by users and assigning it to a variable named degf. It then performs calculations on degF to arrive at the Celsius equivalent, which is assigned to a variable named degc. Finally, it assigns the value of dege as the innerHTML value of the element with the id value Value 4. Below the closing ) for the convert() function, but before the closing tag, enter the following statement to add an event listener: document.getElementById("button"). addEventListener("click", convert, false) 5. Save your work, open index.htm in your browser, enter-40 in the Enter temp in F box, and then click the Convert to C button. -40 Fahrenheit is actually equivalent to -40 Celsius. However, the formula incorrectly calculates that -40 F is equivalent to -57.7C. This is because the calculations in the equation must take place in a different order than the order of precedence dictates. 6. Return to the index.htm file in your text editor, and then add two sets of parentheses to the first statement in the convert() function to modify the order in which the calculations are performed, as follows: var degc = degs 32) - 15/9): 7. Save your work, refresh or reload index.htm in your browser, enter - 40 in the Enter temp in F box, and then click the Convert to C button. As Figure 2-18 shows, the temperature is now calculated correctly as -40C

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

=+ what roles should government play in them ?

Answered: 1 week ago

Question

=+ Why do we have markets and, according to economists,

Answered: 1 week ago