-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEjercicio 10.html
More file actions
64 lines (49 loc) · 1.33 KB
/
Ejercicio 10.html
File metadata and controls
64 lines (49 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang=en dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script>
function coste_hotel(numero_noches){
var resultado = 140 * numero_noches;
return resultado;
}
function coste_avion(destino, noches){
var coste = 0;
if (destino=="Oviedo"){
coste = 325;
}else if (destino=="Tokyo"){
coste = 1200;
}else if (destino=="Madrid"){
coste = 200;
}else if (destino=="Barcelona"){
coste = 150;
}
if (noches > 3){
coste = coste / 0.1;
}
return coste;
}
function calcular_coste(){
var numero_noches = document.getElementById("numero_noches").value;
var destino = document.getElementById("Ciudad").value;
var resultado1 = coste_hotel(numero_noches);
var resultado2 = coste_avion(destino, numero_noches);
document.getElementById("resultado").value = resultado1+resultado2;
}
</script>
</head>
<body>
<label>Número de noches que desea alojarse:</label>
<input id="numero_noches" type="text"><br>
<select id="Ciudad">
<option selected="selected" value="Oviedo">Oviedo</option>
<option value="Tokyo">Tokyo</option>
<option value="Madrid">Madrid</option>
<option value="Barcelona">Barcelona</option>
</select><br>
<input onclick="calcular_coste()" value="calcular coste" type="button">
<br><br>
<input id="resultado" type="text">
</body>
</html>