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

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.
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; }
Bash Script Write a script using while-do-done loop to convert the kilometers to miles. - Ask...
Bash Script Write a script using while-do-done loop to convert the kilometers to miles. - Ask the user to input the number of kilometers they need to travel. - Display the number of equivalent miles for the number. Use formula, Kilometers = miles/0.62137 - Every time the loop runs, it should ask the user if they want to continue, if user enters “Y” or “y”, then the loop runs again, if user enters “N” or “n”, then stop the loop...
Task 2.5: Write a script that will ask the user for to input a file name...
Task 2.5: Write a script that will ask the user for to input a file name and then create the file and echo to the screen that the file name inputted had been created 1. Open a new file script creafile.sh using vi editor # vi creafile.sh 2. Type the following lines #!/bin/bash echo ‘enter a file name: ‘ read FILENAME touch $FILENAME echo “$FILENAME has been created” 3. Add the execute permission 4. Run the script #./creafile.sh 5. Enter...
In Kali Linux Write a script that ask the user to enter an IP address and...
In Kali Linux Write a script that ask the user to enter an IP address and a port number, then use the provided entries from the user to perform a query on your local network and determine if the given port is open on the provide network. Need to submit solutions for both below. 1.A short report showing the functionality of your code 2. your bash script
Write a function in bash that takes an input temperature (Celsius or Fahrenheit) from the user...
Write a function in bash that takes an input temperature (Celsius or Fahrenheit) from the user converts that temperature Celsius to Fahrenheit, Fahrenheit to Celsius, Celsius to Kelvin and Fahrenheit to Kelvin
Code in Java Change the instructionLabel to ask the user to enter a numeric value into...
Code in Java Change the instructionLabel to ask the user to enter a numeric value into the textField and click the button to convert the entered value from kilometers to miles (1.609344 km = 1 mile). When the actionButton on the form is clicked, ActionWindow should take the value entered in the textField, convert it from kilometers to miles, and display the result in the resultField. import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT