59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
function calculaTotales() {
|
|
let nDias = document.getElementById("nDias").value;
|
|
let destino = document.getElementById("destino").value;
|
|
let costeVuelo = document.getElementById("costeVuelo");
|
|
let costeHotel = document.getElementById("costeHotel");
|
|
let tasasViaje = document.getElementById("tasasViaje");
|
|
let costeAlquilerCoche = document.getElementById("costeAlquilerCoche");
|
|
let costeTotal = document.getElementById("costeTotal");
|
|
|
|
let PVPHOTEL;
|
|
let PVPALQUILERCOCHE =
|
|
parseInt(nDias) >= 7 ? 40 : parseInt(nDias) <= 3 ? 80 : 60;
|
|
let IVA = 1.21;
|
|
|
|
let tasas = 0;
|
|
switch (destino) {
|
|
case "500":
|
|
tasas = 50;
|
|
PVPHOTEL = 90;
|
|
break;
|
|
case "1000":
|
|
tasas = 100;
|
|
PVPHOTEL = 110;
|
|
break;
|
|
case "1200":
|
|
tasas = 120;
|
|
PVPHOTEL = 80;
|
|
break;
|
|
}
|
|
if (nDias >= 12) {
|
|
tasas = 0;
|
|
}
|
|
|
|
let vuelo = parseInt(destino);
|
|
let hotel = nDias * PVPHOTEL;
|
|
let alquilerCoche = nDias * PVPALQUILERCOCHE;
|
|
let total = parseFloat((vuelo + hotel + tasas + alquilerCoche) * IVA).toFixed(
|
|
2
|
|
);
|
|
|
|
costeVuelo.value = vuelo;
|
|
costeHotel.value = hotel;
|
|
tasasViaje.value = tasas;
|
|
costeAlquilerCoche.value = alquilerCoche;
|
|
costeTotal.value = total;
|
|
}
|
|
|
|
class Persona {
|
|
constructor(a) {
|
|
this.nombre = a;
|
|
}
|
|
|
|
obtenerNombre() {
|
|
return this.nombre;
|
|
}
|
|
}
|
|
|
|
let personas = new Persona('hola, ');
|
|
console.log(personas.obtenerNombre()); |