Editorial:

Input: Read the age and weight of the visitor as input.

Strategy: Initialize a variable ticket_price to store the calculated ticket price.

Use a series of if-else statements to check the conditions defined by the park's pricing guidelines:

  • If the age is less than 3 or greater than or equal to 70, set ticket_price to 0 (free ticket).

  • If the age is between 3 and 12 (inclusive), set ticket_price to $10.

  • If the age is between 65 and 69 (inclusive), set ticket_price to $15.

  • If the age is between 30 and 40 (inclusive) and the weight is greater than 75 kg, set ticket_price to $18.

  • For all other cases, set ticket_price to the regular price of $20.

Output: Finally, check the value of ticket_price and output the result accordingly:

If ticket_price is 0, print "Free."

Otherwise, print the ticket_price.

Statistics

93% Solution Ratio
SharifsoloEarliest, 5M ago
Tanvir_580Fastest, 0.0s
user.8526Lightest, 5.1 MB
user.6748Shortest, 279B
Toph uses cookies. By continuing you agree to our Cookie Policy.