Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an application interface that converts Fahrenheit temperatures to Celsius

ID: 3890001 • Letter: C

Question

Create an application interface that converts Fahrenheit temperatures to Celsius temperatures by using prompt and alert statements. The prompt dialog box should look like this:

The alert dialog box should look like this:

To convert Fahrenheit to Celsius, first subtract 32 from the Fahrenheit temperature. Then, multiply that result by 5/9.

Review the script element in the head section and note that it’s empty. You’ll write the code for this application within this element.

Develop this program application.

Once you have done the above task to see if the temperature conversion works fine, next complete the following:

You’ll now learn to add data validation to the application you created in the above problem. You’ll also let the user do multiple conversions before ending the application. This is the dialog box for an invalid entry:

Add data validation to the application so it won’t do the conversion until the user enters a Fahrenheit temperature between -100 and 212. If the entry is invalid, a dialog box like the one above should be displayed.

Add a loop to the code so the user can do a series of calculations without restarting the application. To end the application, the user must enter 999 as the temperature.

Here is code to get you started:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Convert from Fahrenheit to Centigrade</title>

<script>

</script>

</head>

<body>

<main>

<h1>Thanks for using the temperature converter</h1>

</main>

</body>

</html>

Explanation / Answer

Attached images are not visible.Please check the below code and comment if any problems

Thanks.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Convert from Fahrenheit to Centigrade</title>
<script>
function convertTempreture()
       {
           var ftemp = prompt("Please enter Temprature in Fahrenheit , value between -100 and 212. Enter 999 to Stop.");
           //After user enter the value and Subit , this code will be executed
           if(ftemp == 999)
           {
               //If user enter 999 then Do nothing
              
           }
           else{
               /**
               *Validation
               * 1. Check Entered value is Number or not
               * 2. Check Value between -100 and 212
               */
               if( isNaN(ftemp) || !(ftemp >= -100 && ftemp <= 212)){
                   //Display Alert if not valid
                   alert("Invalid Temperature. Please renter value between -100 and 212");
                   //Prompt again to enter valid value
                   convertTempreture();
               }
               else{
                   var ctemp = (ftemp-32)*(5/9);
                   alert("Temperature in Celsius is ::"+ctemp.toFixed(2));
                   //Prompt again for next conversion
                   convertTempreture();
               }
              
           }
       }
</script>
</head>
   <!-- call conversion function when Page is loaded -->
<body>
<main>
<h1>Thanks for using the temperature converter</h1>
</main>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote