Device Sync
This commit is contained in:
@@ -1,81 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Lab 2</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Theme Park Tickets</h1>
|
||||
<script>
|
||||
// Constant values
|
||||
const CHILD_TICKET_PRICE = 9.99;
|
||||
const ADULT_TICKET_PRICE = 19.99;
|
||||
const SENIOR_TICKET_PRICE = 14.99;
|
||||
const HST_TAX = 0.13;
|
||||
|
||||
// Unassigned for now, assign later
|
||||
var ticketType;
|
||||
var ticketPrice;
|
||||
var userAge;
|
||||
var firstName;
|
||||
var lastName;
|
||||
var email;
|
||||
var phone;
|
||||
var tax;
|
||||
var total;
|
||||
var freeRides;
|
||||
|
||||
// Ask for user details
|
||||
firstName = prompt("First Name:");
|
||||
lastName = prompt("Last Name:");
|
||||
email = prompt("Email:");
|
||||
phone = prompt("Phone:");
|
||||
userAge = prompt("Enter your age:");
|
||||
|
||||
// Determine ticket price
|
||||
if (userAge < 12) {
|
||||
ticketPrice = CHILD_TICKET_PRICE;
|
||||
ticketType = "Child";
|
||||
} else if (userAge <= 59) {
|
||||
ticketPrice = ADULT_TICKET_PRICE;
|
||||
ticketType = "Adult";
|
||||
} else {
|
||||
ticketPrice = SENIOR_TICKET_PRICE;
|
||||
ticketType = "Senior";
|
||||
}
|
||||
|
||||
// Determine free ride coupons
|
||||
if (ticketType === "Child") {
|
||||
freeRides = 0;
|
||||
} else if (ticketType === "Adult") {
|
||||
freeRides = 2;
|
||||
} else {
|
||||
freeRides = 1;
|
||||
}
|
||||
|
||||
// Caluclate tax and total
|
||||
tax = ticketPrice * HST_TAX;
|
||||
total = ticketPrice + tax;
|
||||
|
||||
// Display to console
|
||||
console.log("==========================================");
|
||||
console.log(" Theme Park Ticket Receipt ");
|
||||
console.log("==========================================");
|
||||
console.log("Customer Name: ", firstName, lastName);
|
||||
console.log("Email: ", email);
|
||||
console.log("Phone: ", phone);
|
||||
console.log("------------------------------------------");
|
||||
console.log("Ticket Type: ", ticketType);
|
||||
console.log("Base Price: $", ticketPrice.toFixed(2));
|
||||
console.log("Tax (13%): $", tax.toFixed(2));
|
||||
console.log("TOTAL: $", total.toFixed(2));
|
||||
console.log("------------------------------------------");
|
||||
console.log("Free Ride Coupons Earned: ", freeRides);
|
||||
console.log("==========================================");
|
||||
console.log(" Have a fun and safe day at the park! ");
|
||||
console.log("==========================================");
|
||||
</script>
|
||||
</body>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Lab 2</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Theme Park Tickets</h1>
|
||||
<script>
|
||||
// Constant values
|
||||
const CHILD_TICKET_PRICE = 9.99;
|
||||
const ADULT_TICKET_PRICE = 19.99;
|
||||
const SENIOR_TICKET_PRICE = 14.99;
|
||||
const HST_TAX = 0.13;
|
||||
|
||||
// Unassigned for now, assign later
|
||||
var ticketType;
|
||||
var ticketPrice;
|
||||
var userAge;
|
||||
var firstName;
|
||||
var lastName;
|
||||
var email;
|
||||
var phone;
|
||||
var tax;
|
||||
var total;
|
||||
var freeRides;
|
||||
|
||||
// Ask for user details
|
||||
firstName = prompt("First Name:");
|
||||
lastName = prompt("Last Name:");
|
||||
email = prompt("Email:");
|
||||
phone = prompt("Phone:");
|
||||
userAge = prompt("Enter your age:");
|
||||
|
||||
// Determine ticket price
|
||||
if (userAge < 12) {
|
||||
ticketPrice = CHILD_TICKET_PRICE;
|
||||
ticketType = "Child";
|
||||
} else if (userAge <= 59) {
|
||||
ticketPrice = ADULT_TICKET_PRICE;
|
||||
ticketType = "Adult";
|
||||
} else {
|
||||
ticketPrice = SENIOR_TICKET_PRICE;
|
||||
ticketType = "Senior";
|
||||
}
|
||||
|
||||
// Determine free ride coupons
|
||||
if (ticketType === "Child") {
|
||||
freeRides = 0;
|
||||
} else if (ticketType === "Adult") {
|
||||
freeRides = 2;
|
||||
} else {
|
||||
freeRides = 1;
|
||||
}
|
||||
|
||||
// Caluclate tax and total
|
||||
tax = ticketPrice * HST_TAX;
|
||||
total = ticketPrice + tax;
|
||||
|
||||
// Display to console
|
||||
console.log("==========================================");
|
||||
console.log(" Theme Park Ticket Receipt ");
|
||||
console.log("==========================================");
|
||||
console.log("Customer Name: ", firstName, lastName);
|
||||
console.log("Email: ", email);
|
||||
console.log("Phone: ", phone);
|
||||
console.log("------------------------------------------");
|
||||
console.log("Ticket Type: ", ticketType);
|
||||
console.log("Base Price: $", ticketPrice.toFixed(2));
|
||||
console.log("Tax (13%): $", tax.toFixed(2));
|
||||
console.log("TOTAL: $", total.toFixed(2));
|
||||
console.log("------------------------------------------");
|
||||
console.log("Free Ride Coupons Earned: ", freeRides);
|
||||
console.log("==========================================");
|
||||
console.log(" Have a fun and safe day at the park! ");
|
||||
console.log("==========================================");
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user