Exercise 10: Temperature Conversions

Date completed: 09/06/2018

Implement the following integer methods:

  1. Function celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation:
    celsius = 5.0 / 9.0 * ( fahrenheit - 32 );
  2. Function fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation:
    fahrenheit = 9.0 / 5.0 * celsius + 32;
  3. Use these functions to write a script that enables the user to enter either a Fahrenheit or a Celsius temperature and displays the Celsius or Fahrenheit equivalent.

Your HTML5 document should contain two buttons - one to initiate the conversion from Fahrenheit to Celsius and one to initiate the conversion from Celsius to Fahrenheit.

Solution

Temperature Conversions

DetailsFahrenheitCelsius
Convert from Fahrenheit to Celsius
DetailsCelsiusFahrenheit
Convert from Celsius to Fahrenheit