Menu
CoddyTech

Recap - Ticket Price

Part of the PowerShell Basics section of Coddy's PowerShell journey. Lesson 15 of 28.

challenge icon

Challenge

Easy

A cinema sells tickets by age, with half price on Tuesdays. Write the script that prints a ticket.

  1. Read a whole number with the prompt Age, then a day name with the prompt Day.
  2. Under 12 the ticket is Child and costs 8. From 65 up it is Senior and costs 9. Every other age is Adult and costs 14.
  3. On a Tuesday, a ticket that is not a Child ticket costs half its price. Day names are matched whatever their case.
  4. Print Ticket: and the type, then Price: and the price with 2 decimals.

With the input 35 and tuesday, your script prints:

Age: 35
Day: tuesday
Ticket: Adult
Price: 7.00

With 10 and Saturday, it prints Ticket: Child and Price: 8.00.

Try it yourself

# Read the age and the day, then print the ticket

All lessons in PowerShell Basics