Skip to content

Movie Ticket Vendor

  • Project
  • 1 hint
  • 7 of 7 in this chapter

Context

A ticket vendor is typically someone who’s at a theater and sells tickets. He/she usually lets you pick which movie, while also offering additional info about the movie to help you decide which one to watch. We would like to automate this process with programming.

Challenge

As part of this project, you will build a program that acts as an automated movie ticket vendor.

  • Use a case statement to allow for multiple cases of different movies that the user can choose from to watch.
  • Once the user’s movie has been picked (A variable picked_movie will be declared at the beginning)
  • Tell him/her the cost, time, and rating, in a well-written print statement.

Hints

Hint 1Hint 1

Hint 2

Solution

Swift
var picked_movie = "Cars 3"

switch picked_movie {
 case "Cars 3": print("This movie costs $15.99 and is rated 5/5 stars. Next showing is at 10:30pm")
 case "Fallout": print("This movie costs $18.99 and is rated 4.6/5 stars. Next showing is at 11:30pm")
 case "Men in Black": print("This movie costs $12.99 and is rated 3.1/5 stars. Next showing is at 8:15pm")
default: print("I'm not sure what movie that is")
} 

Give the project a try first.