56 lines
2.5 KiB
HTML
56 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
|
|
-->
|
|
<html>
|
|
<head>
|
|
<title>TODO supply a title</title>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<script>
|
|
var toCelcius = prompt("If you want to convert to celcius, type true");
|
|
var userInput = prompt("Enter a temperatuire to convert to " + (toCelcius === "true" ? "Celcius" : "Fahrenheit"));
|
|
|
|
if (toCelcius) {
|
|
var output = 5/9 * (userInput - 32); //outputs Celcius
|
|
} else {
|
|
var output = (userInput * 5 / 9) + 32; //outputs Fahrenheit
|
|
}
|
|
|
|
if (toCelcius) {
|
|
if (output <= -18) {
|
|
var message = "Bundle up! It's really freezing out there!";
|
|
} else if (output <= 0) {
|
|
var message = "It's pretty cold, with a chance of snow.";
|
|
} else if (output <= 15) {
|
|
var message = "Don't forget your jacket. It's still chilly outside.";
|
|
} else if (output <= 27) {
|
|
var message = "Perfect lovely weather... Unless it rains.";
|
|
} else if (output <= 35) {
|
|
var message = "Nice and warm, go for a swim!";
|
|
} else {
|
|
var message = "It's really hot! Probably best to stay in an air conditioned spot.";
|
|
}
|
|
} else {
|
|
if (output <= 0) {
|
|
var message = "Bundle up! It's really freezing out there!";
|
|
} else if (output <= 32) {
|
|
var message = "It's pretty cold, with a chance of snow.";
|
|
} else if (output <= 59) {
|
|
var message = "Don't forget your jacket. It's still chilly outside.";
|
|
} else if (output <= 80) {
|
|
var message = "Perfect lovely weather... Unless it rains.";
|
|
} else if (output <= 95) {
|
|
var message = "Nice and warm, go for a swim!";
|
|
} else {
|
|
var message = "It's really hot! Probably best to stay in an air conditioned spot.";
|
|
}
|
|
}
|
|
|
|
document.write("Temperature output: "+ output + (toCelcius === "true" ? " Celcius" : " Fahrenheit") + "<br> <br>" + message);
|
|
|
|
</script>
|
|
</head>
|
|
</html>
|