-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
87 lines (75 loc) · 3 KB
/
index.html
File metadata and controls
87 lines (75 loc) · 3 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Joe's Hotdog Stand Order</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
text-align: center;
color: #2e985c;
}
.order-summary {
margin-top: 20px;
}
.order-summary h2 {
color: #ec6249;
}
table {
width: 50%;
margin: 0 auto;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 10px;
text-align: center;
}
</style>
</head>
<body></body>
<h1>Welcome to Joe's Hotdog Stand!</h1>
<script>
const PRICE_HOTDOG = 4.80;
const PRICE_FRIES = 3.95;
const PRICE_DRINK = 1.99;
function showMoney(amount) {
return amount.toFixed(2);
}
let numDogs = parseInt(prompt("How many hotdogs would you like?"));
let numFries = parseInt(prompt("How many fries would you like?"));
let numSoda = parseInt(prompt("How many sodas would you like?"));
let subtotal = (numDogs * PRICE_HOTDOG) + (numFries * PRICE_FRIES) + (numSoda * PRICE_DRINK);
let discount = 0;
if (subtotal >= 25) {
discount = subtotal * 0.10;
}
let subtotalAfterDiscount = subtotal - discount;
const TAX_RATE = 0.0625;
let taxAmount = subtotalAfterDiscount * TAX_RATE;
let finalTotal = subtotalAfterDiscount + taxAmount;
document.write("<div class='order-summary'>");
document.write("<h2>Order Summary:</h2>");
document.write("<table>");
document.write("<tr><th>Item</th><th>Quantity</th><th>Cost</th></tr>");
document.write("<tr><td>Hotdogs</td><td>" + numDogs + "</td><td>$" + showMoney(numDogs * PRICE_HOTDOG) + "</td></tr>");
document.write("<tr><td>Fries</td><td>" + numFries + "</td><td>$" + showMoney(numFries * PRICE_FRIES) + "</td></tr>");
document.write("<tr><td>Sodas</td><td>" + numSoda + "</td><td>$" + showMoney(numSoda * PRICE_DRINK) + "</td></tr>");
document.write("<tr><td colspan='2'><strong>Subtotal</strong></td><td>$" + showMoney(subtotal) + "</td></tr>");
if (discount > 0) {
document.write("<tr><td colspan='2'><strong>Discount</strong></td><td>-$" + showMoney(discount) + "</td></tr>");
}
document.write("<tr><td colspan='2'><strong>Subtotal after Discount</strong></td><td>$" + showMoney(subtotalAfterDiscount) + "</td></tr>");
document.write("<tr><td colspan='2'><strong>Tax</strong></td><td>$" + showMoney(taxAmount) + "</td></tr>");
document.write("<tr><td colspan='2'><strong>Final Total</strong></td><td>$" + showMoney(finalTotal) + "</td></tr>");
document.write("</table>");
document.write("</div>");
</script>
</body>
</html>