-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
50 lines (41 loc) · 1.51 KB
/
script.js
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
//Sobre o sistema:
//Carne - 400 g por pessoa + de 6 horas - 650
//Cerveja 1200 ml por pessoa + 6 horas - 2000 ml
//Refrigerante/Água - 1000 ml por pessoa + 6 horas - 1500 ml
// crianças valem por 0.5
let inputAdult = document.getElementById("adult");
let inputChildren = document.getElementById("children");
let inputDuration = document.getElementById("duration");
let result = document.getElementById("result")
function calculate(){
let adult = inputAdult.value;
let children = inputChildren.value;
let duration = inputDuration.value;
let amountOfMeat = meatPerPerson(duration) * adult + (meatPerPerson(duration) / 2 * children)
let amountOfBeer = beerPerPerson(duration) * adult //Criança nao bebe cerveja KKKKK
let amountOfDrink = drinkPerPerson(duration) * adult + (drinkPerPerson(duration) / 2 * children)
result.innerHTML = `<center><p>${amountOfMeat / 1000} kg de carne</p></center>`
result.innerHTML += `<center><p>${Math.ceil(amountOfBeer / 355)} latas de cerveja</p></center>`
result.innerHTML += `<center><p>${Math.ceil(amountOfDrink / 2000)} garrafas de 2L de bebida</p></center>`
}
function meatPerPerson(duration){
if(duration >= 6){
return 650;
} else {
return 400;
}
}
function beerPerPerson(duration){
if(duration >= 6){
return 2000;
} else {
return 1200;
}
}
function drinkPerPerson(duration){
if(duration >= 6){
return 1500;
} else {
return 1000;
}
}