Question

Write a program in JavaScript, that take (07) days temperatures from user and display the temperature...

Write a program in JavaScript, that take (07) days temperatures from user and display the temperature in centigrade, Fahrenheit and kelvin on web browser.

Hint: you can use array, for loop .

0 0
Add a comment Improve this question Transcribed image text
Answer #1

HTML AND JAVASCRIPT CODE:

<html>
<head>
<title>Temperatures</title>

</head>
<body>
<script>

//variable for counter
var i=0;

//empty array
var temp=[];

//getting temperature from the user
for(i=0;i<7;i++)
{

   temp[i]=prompt("Enter the temperature(celsius) for day ".concat(i+1));
}

// printing the table
document.write("<table border=1>");
document.write("<tr><th>Celsius</th><th>Fahrenheit</th><th>Kelvin</th>");

//looping to convert the temperatures
for(i=0;i<7;i++)
{
   //converting to fahrenheit
   var f= (temp[i] *(9/5))+ 32;
  
   //converting to kelvin
   var k= parseFloat(temp[i])+273.15;
   var cel=parseFloat(temp[i]).toFixed(2);
   var fah=parseFloat(f).toFixed(2);
   var kel=parseFloat(k).toFixed(2);
  
   //displaying the temperatures
   document.write("<tr><td>"+cel+"</td><td>"+fah+"</td><td>"+kel+"</td></tr>");
}

document.write("</table>");

</script>
</body>
</html>

SCREENSHOT FOR OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Write a program in JavaScript, that take (07) days temperatures from user and display the temperature...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a...

    Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a real number. After the temperature is entered display the temperature in Celsius. Your program will then prompt the user if they want to continue. If the character n or N is entered the program will stop; otherwise, the program will continue. After your program stops accepting temperatures display the average of all the temperatures entered in both Fahrenheit and Celsius. Be sure to use...

  • in Java, temperature problem Create a package named temperature and create a program that has a...

    in Java, temperature problem Create a package named temperature and create a program that has a while loop. • • Inside the while loop, your program will prompt the user for temperature in Centigrade. If the Centigrade value read in is <= -100. the loop will exit. Otherwise, your program will compute the Fahrenheit equivalent temperature. Inside the while loop, your program will print out the Centigrade and Fahrenheit temperatures. Keep a count of the valid user inputs and a...

  • Write a program that displays a table of Celsius temperatures 0 through a number entered by...

    Write a program that displays a table of Celsius temperatures 0 through a number entered by the user and their Fahrenheit equivalents as in the figure below. The formula for converting a Celsius temperature to a Fahrenheit temperature is: F = 9 / 5 * C + 32 where F is the Fahrenheit temperature and C is the Celsius Temperature. Your program must use a 'for' loop. Display all temperatures to one decimal place. Write a program that displays a...

  • Write a program in C that will convert all 12 months' average temperature from Celsius to...

    Write a program in C that will convert all 12 months' average temperature from Celsius to Fahrenheit. You need to create an array named aye jump and prompt the user to input average temperature in Celsius for all 12 months. After that, you need to develop a user temperatures from Celsius to Fahrenheit and pass the array as reference and convert all temperatures from Celsius to Fahrenheit. Next, compute the average temperature of the year and assign it to a...

  • Write a Java program that converts Centigrade temperatures to Fahrenheit temperatures. The formula is F =...

    Write a Java program that converts Centigrade temperatures to Fahrenheit temperatures. The formula is F = 9/5C + 32 F is the Fahrenheit temperature and C is the centigrade temperature.

  • Write a program that allows a user to view a table of temperature conversion. The user...

    Write a program that allows a user to view a table of temperature conversion. The user should be able to enter a starting value and an ending value in to textboxes. Your program will display a list of temperature conversion from Celsius to Fahrenheit in a text area like the example below: You can choose any color, design and font for this interface. Use javafx scene builder for program. When you click on "Display" button it read values from text...

  • In Javascript: While loop: use a while loop to calculate and display the Kelvin temperature values...

    In Javascript: While loop: use a while loop to calculate and display the Kelvin temperature values for each Fahrenheit temperature value range from 0 to 100 in increment of 10. use the formula tk = (tf -32) x 5/9 + 273.15    The values should be displayed exactly as shown: -17, -12, -6, -1, 4, 10, 15, 21, 26, 32, 37

  • In Python, write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as...

    In Python, write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=(9/5)C+32 The program should ask the user to enter a temperature in Celsius, then display the temperature converted to Fahrenheit.

  • Write a Python program with a function that will take as input from the user the...

    Write a Python program with a function that will take as input from the user the temperature in Celsius and will convert and display temperature values in both Fahrenheit and Celsius, using the equation: F = (C ∗ 9/5)+ 32 Note: below is what a sample input line to your program should look like and the resulting output. User input lines always start with >>>. This convention will be used for all of the problem sets. >>>Enter temperature in Celsius:...

  • C++ optional exercise. You are going to convert temperatures in this program. You will give the...

    C++ optional exercise. You are going to convert temperatures in this program. You will give the user the choice of converting Fahrenheit to Celsius or Celsius to Fahrenheit. With the correct answer you will also display the number entered. The user should have the option to convert as many temperatures as they want. Use functions and a menu (also a function) and, assume they will convert at least one temperature. When finished upload and submit the zipped project. the formulas...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT