Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active November 24, 2022 14:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save McLarenCollege/aebaa613e39042fe0a141144f28b7792 to your computer and use it in GitHub Desktop.
Ticket Price Child Adult

Given a person's age and a day ,write the code for the following scenario:

If the person is an Adult (age >=18) , the ticket price on Weekends is 100 and on weekdays is 80.

If the person is a child (age <18), the ticket price is always half of the adult price for that particular day.

CODE TEMPLATE


let age = 15;
let day = "Sunday";
let price ;
// write your logic here to determine the price
console.log(price);

@nkwoguctl
Copy link

let age = 15;
let day = "Sunday";
let price ;
// write your logic here to determine the price
if (day != "Sunday" && day != "Saturday") {
if (age >= 18){
price = 80
}else {
price = 80/2;
}
}else{
if(age >= 18){
price = 100;
}else {
price = 100/2
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment