How to Write a program that allows the user to buy movie tickets? (in c++)?

Question by Delaram Ra: How to Write a program that allows the user to buy movie tickets? (in c++)?
Decision Making
Write a program that allows the user to buy movie tickets. The program will show the movie listing, ask the user to select a movie, a show time, and the number of tickets. Then the program asks the user to pay for the tickets.
Program Design
The following structure chart is the design of the program:

You can change the name of the functions if you like, but main can only call the three functions as shown. You can add more functions under printMovieListing, sellTickets, getPayment as you see fit.
Detail
Tasks of printMovieListing
-Print a menu with movie names (use any movie names you like, but some must be 3D movies)
-Ask the user for a movie choice (an integer)
-Print the movie times (make up your own movie times with both am and pm times, and there should be 2 different times: one for regular movies and one for 3D movies)
-Ask the user to choose a time (format: 2:45pm)
-Return the movie time and a boolean to show whether or not the movie is a 3D movie. You will need to convert the movie time to an integer format to return it – it’s up to you to decide how to convert the movie time into an integer, but make sure you document your conversion routine.
Tasks of sellTickets
-Ask the user for the number of tickets for each of the 3 types of tickets: adult, student, and CIS 15AG student (lowest rate!)
-Based on the time and the 3D boolean, print the price for each type of tickets (There are 4 different prices, depending on what the user selects: am and 3D, am and not 3D, pm and 3D, pm and not 3D. You can make up any price you like)
-Calculate the total price and return to main

Tasks of getPayment
-Print the total price
-Ask the user for a payment
-Based on the payment, print 1 of 3 different acknowledge messages, depending whether the payment is greater than, equal to, or less than the total price.

You can run the file lab5.exe to see how the program should work. (lab5.exe has the extra credit code)

Turn in: source code, test output (you should test all paths – full credit will be given only if you test all paths), and a structure chart

Extra Credit (2pts)
Add the following user validation checking
-If the user enters an invalid movie choice, print an appropriate error message and return an error code back for main to end
-If the user enters an invalid movie time (hour must be 1-12, minute must be 0-59, the last 2 characters should be am or pm). If there is an invalid time, print an appropriate error message and return an error code back for main to end. You don’t have to check that the user enters a time that matches the movie time.
-If the user chooses 0 ticket to buy, print an appropriate message and return an error code for main to end

In all 3 cases, do not use the exit function to end the program.

You will also need to do additional testing: invalid movie choice, invalid hour, invalid minute, invalid am/pm, and 0 ticket

Best answer:

Answer by cornflake#1
Sorry – my code is far, far, far too long to post here.

We’re talking 3 weeks worth of intense coding, cross-checking and debugging.

I’ve got it down to only 11 pages at size 10, which is obviously too long to clutter up the servers at Y!A with.

start with:

main ()
{
}

What do you think? Answer below!

Get the book now