jda_m06/uf01/Exercicis UF1_1. Solucions-20211107/ex09_convCelsius.html
2022-02-16 16:13:08 +01:00

32 lines
1 KiB
HTML
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Conv Celsius Farenheit</title>
</head>
<body>
<script>
/* Crear una aplicació que permeti realitzar la conversió entre temperatures de ºC a ºF i de ºF a ºC,
dacord amb la següent fórmula:
ºF = (9.0/5.0)* (ºC)+32.
El programa ha de demanar a lusuari quina conversió ha de fer i la temperatura a convertir. */
var conv = parseInt(prompt("Per convertir de Celsius a Farenheit escriu 1, per convertir de Farenheit a Celsius escriu 2", 1));
var degrees = parseInt(prompt("Escriu els graus", "100"));
if (conv == 1) {
var far = (9.0 / 5.0) * degrees + 32;
document.write("Graus Farenheit = " + far);
} else {
var cel = 5.0 * (degrees - 32) / 9.0;
document.write("Graus Celsius = " + cel);
}
</script>
</body>
</html>