forked from dwolverton/fe-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconey-island.js
56 lines (50 loc) · 1.11 KB
/
coney-island.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
51
52
53
54
55
56
var totalBill = 0;
totalBill += getPriceOfDog(true, false);
totalBill += getPriceOfFries(true, true);
totalBill += getPriceOfDog(false);
totalBill += getPriceOfFries(false, false);
totalBill += getPriceOfDrink("sprite");
totalBill += getPriceOfDrink("water");
totalBill += calcTax(totalBill);
console.log("Your bill is $" + totalBill.toFixed(2));
function getPriceOfDog(hasChili, addMeat) {
var price;
if (hasChili) {
price = 2.00;
} else {
price = 1.50;
}
if (addMeat) {
price += 0.50;
}
return price;
}
function getPriceOfFries(addCheese, addChili) {
var price = 2.00;
if (addCheese) {
price += 0.75;
}
if (addChili) {
price += 0.75;
}
return price;
}
function getPriceOfDrink(choice) {
switch (choice) {
case "coke":
case "diet coke":
case "sprite":
case "fanta":
return 1.50;
case "coffee":
case "tea":
return 2.00;
case "lemonade":
return 3.00;
default:
return 0.00;
}
}
function calcTax(subtotal) {
return subtotal * 0.06; // 6% tax
}