AP Computer Science
Museum Ticket Generator
View Project (Try using discount codes "KIDSRULE" and "FREEFRIDAY")
var age;
var day;
var discountCode;
var price;
var weekday;
onEvent("calculateButton", "click", function() {
discountCode = getText ('discountInput');
day = getText ('dayDropdown');
age = getNumber ('ageDropdown');
if ((day == ('Monday')||day == ('Tuesday')||day == ('Wednesday')||day == ('Thursday')||day == ('Friday'))){
weekday = 'true';
}
if (day == ('Saturday') || day == ('Sunday')){
price = ('$10');
}else if ((weekday == 'true') && (age <= 10) && (discountCode.toLowerCase() == ('kidsrule'))){
price = ('$0');
}else if (discountCode.toLowerCase() == ("freefriday") && day == ('Friday')){
price = ('$0');
}else if ((weekday == 'true') && (age < 19)){
price = ('$5');
}else{
price = ('$10');
}
setText('ticketOutput','Thank you for purchasing a ticket! The price today will be ' + (price) + ' Please enjoy your day!');
}
);