Question

In: Computer Science

Java Script Ask the user for a Fahrenheit temperature Write the code needed to convert a...

Java Script

Ask the user for a Fahrenheit temperature
Write the code needed to convert a Fahrenheit temperature into a Celsius temperature. Use an alert box to show the result
Ask the user for a Celsius temperature
Write a function to convert from Celsius to Fahrenheit; use an alert box to show the results
Decide on two other conversions (meters to feet, pounds to kilos, other)
Ask the user for numbers to be converted; be sure to tell them what you are converting from and to
Write two more functions that will do the conversions; use an alert box to show the results
Write all results to the document, correctly formatted in complete sentences.

Solutions

Expert Solution

Below is the solution:

<!DOCTYPE html>

<html lang="en">

<head>

  <title>Converter</title>

  <meta charset="UTF-8">

  <style>

    #container {

      margin: 0 auto;

      width: 400px;

      padding: 100px;

      margin-top: 200px;

    }

  </style>

</head>

</body>

<div id="container">

  <h1>Converter</h1>

  Enter value in Fahreheight: <input id="fahrenheit" type="text"><br><br>

  Enter value in Celcius: <input id="celcius" type="text"><br><br>

  Enter value in Meter: <input id="meter" type="text"><br><br>

  Enter value in Pound: <input id="feet" type="text"><br><br>

  <input value="add" type="button" onClick="addLabelTextBox()">

</div>

</body>

<script>

  //declare variable

  var fahrenheit = document.getElementById('fahrenheit').value; //take value by id

  var celcius = document.getElementById('celcius').value; //take value by id

  var meter = document.getElementById('meter').value; //take value by id

  var feet = document.getElementById('feet').value; //take value by id

  function addLabelTextBox() { //call function

    convertToCelcius = (fahrenheit - 32) * 0.5555; //convert to celcius

    convertToFahreheight = (celcius * 1.8) + 32; //convert to fahrenheight

    convertToFeet = (meter * 3.28084); //convert to feet

    convertToMeter = (feet * 0.3048); //convert to meter

    //display the all values

    alert("Temptarue of Fahrenheight is " + fahrenheit + " into celcius is : " + convertToCelcius + " \n Temptarue of Celcius is " + celcius + " into Fahrenheight is : " + convertToFahreheight + "\n Meter of " + meter + " in Feet is: " + convertToFeet + "\n Feet of " + feet + " in Metet is: " + convertToMeter);

  }

</script>

</html>

sample output:


Related Solutions

Write a fragment of MIPS code to convert temperature in Kelvin to Fahrenheit
Write a fragment of MIPS code to convert temperature in Kelvin to Fahrenheit
Write a java code to ask the user for a string, and assuming the user enters...
Write a java code to ask the user for a string, and assuming the user enters a string containing character "a", your java program must convert all "a" to "b" in the string so for example if user types : "AMAZON" , your program must convert it to "BMBZON" the driver program must ask : enter a string containing "a" or "A" --------- (user enters string) then it should say; HERE IS YOUR NEW STRING ---------- (string with all a's...
In Java: Write a program called F2C that allows the user to convert from degrees Fahrenheit...
In Java: Write a program called F2C that allows the user to convert from degrees Fahrenheit to degrees Celsius. The program should prompt for a temperature in Fahrenheit and output a temperature in Celsius. All calculations should be done in in ints, so be careful of truncation.
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in...
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in Celsius and the program Coverts the input to Fahrenheit using the following formula T(°F) = T(°C) × 1.8 + 32 submit the source code Design output Load: 1. Design (Pseudocode ) 2. Source file (Java file, make sure to include comments) 3. Output file (word or pdf or jpig file)
1. Write a C++ code segment to read 50 temperature values in Fahrenheit and to convert...
1. Write a C++ code segment to read 50 temperature values in Fahrenheit and to convert them to Celsius. You convert a Fahrenheit temperature to Celsius by using the following formula: Celsius = 5.0 / 9 * (Fahrenheit - 32). 2.A client has purchased 20 products in a store. Write a C++ code segment to read the unit price and the number of items of each product and to compute and print the total price of all these products.
in java Write a program that convert a Fahrenheit to Celsius. For conversion, use as many...
in java Write a program that convert a Fahrenheit to Celsius. For conversion, use as many as methods you want
5) Write a JavaScript script that will ask the user to enter in the length of...
5) Write a JavaScript script that will ask the user to enter in the length of the side of a cube. (all the sides of a cube are equal) Based on the value that is entered by the user from the keyboard, calculate each of the following and assign your results to variables. 1. volume of the cube 2. surface area of the cube 3. volume of the largest sphere that could fit in the box. 4. surface area of...
Write a java program that will ask for a Star Date and then convert it into...
Write a java program that will ask for a Star Date and then convert it into the corresponding Calendar date. without using array and methods.
Write a program that asks the user for a Fahrenheit temperature and calls a function name...
Write a program that asks the user for a Fahrenheit temperature and calls a function name Celsius that returns the temperature in Celsius of the Fahrenheit temperature sent to it. Your function will look similar to this: double celsius(double f) { double c; : : return c; }
In C Write a program that prompts the user to enter a Fahrenheit temperature calculate the...
In C Write a program that prompts the user to enter a Fahrenheit temperature calculate the corresponding temperature in Celsius and print it prompt the user if they want to do another temperature conversion if the user enters y, repeat 1), 2) and 3) if the user enters n, then print Bye and exit the program if the user enters any other character, ask the user to enter y or n only Note : c = (5.0/9.0)*(f-32.0) Sample output Enter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT