Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active December 21, 2021 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/bdb6329528e9b014f9af23e4eaeeaa9a to your computer and use it in GitHub Desktop.
Save McLarenCollege/bdb6329528e9b014f9af23e4eaeeaa9a to your computer and use it in GitHub Desktop.
Exercise Name : Ticket Price Using If-else part2

//NOTE: Dont use if-else-if. You can use only if-else

Given two variables age and day, write code to determine the ticket price as per the following rules :

  • For a child (age less than 12) the ticket price is always 50.

  • For a senior citizen(age greater than or equal to 65):

    i) if it is weekend (Saturday/Sunday) the price is 70.
    
    ii)if it is a  weekday the price is 80.
    
  • For everyone else the price is always 100.

  • Here is a link to the branch diagram for the problem https://imgur.com/a/y6ApDYJ

  • As mentioned in the branch diagram your task is to first check the age and then check whether its a weekend or a weekday and then decide the ticket price

CODE TEMPLATE


let age = 21;
let day = 'Monday';
let price;  

//write your code here to determine the price for the given age and day.

console.log("Ticket price is " + price);

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