// This program converts a Fahrenheit temperature to Celsius.
//
// References:
// https://www.mathsisfun.com/temperature-conversion.html
// https://en.wikibooks.org/wiki/JavaScript
"use strict";
const TEMPERATURE_DIFFERENCE = 32;
const TEMPERATURE_RATIO = 5 / 9;
main();
function main() {
let fahrenheit = getFahrenheit();
let celsius = fahrenheitToCelsius(fahrenheit);
displayResults(fahrenheit, celsius);
}
function getFahrenheit() {
let fahrenheit = window.prompt("Enter Fahrenheit temperature:");
fahrenheit = Number(fahrenheit);
return fahrenheit;
}
function fahrenheitToCelsius(fahrenheit) {
let celsius = (fahrenheit - TEMPERATURE_DIFFERENCE) * TEMPERATURE_RATIO;
return celsius;
}
function displayResults(fahrenheit, celsius) {
celsius = celsius.toFixed(1);
document.getElementById("fahrenheit").innerText = fahrenheit;
document.getElementById("celsius").innerText = celsius;
}