← Back to Week 2 Hub
Workbook 2a — Exercise 4
Theater Reservations
Collect reservation details and display a formatted confirmation | Workbook p.21
What You're Building
Ask the user for their name, the date of the show (in MM/dd/yyyy format), and how many tickets they want. Display a formatted confirmation that rearranges the name to "Last, First", converts the date to yyyy-MM-dd format, and uses the correct singular or plural form for "ticket" vs "tickets".
Example Run
Run 1 — Multiple tickets
Enter your name: Geri Johnson
Enter the date (MM/dd/yyyy): 05/13/2023
How many tickets? 3
3 tickets reserved for 2023-05-13 under Johnson, Geri
Run 2 — Single ticket
Enter your name: Mark Rivera
Enter the date (MM/dd/yyyy): 11/02/2023
How many tickets? 1
1 ticket reserved for 2023-11-02 under Rivera, Mark
Flow Diagram
Get name
→
Get date
→
Get tickets
→
Parse name
→
Parse date
→
Format output
Workbook 2a, p.21 — Exercise 4: Theater Reservations