CS3304 Data and Information Structures

Project 1. A Ticket Reservation Program Using Linked List

Purpose: This project is designed to exercise the creation and use of dynamically linked lists in real-world applications. Dynamically linked lists are studied in Chapter 6 (Lists).

Software to use: Use Visual C++ or Visual Studio.Net to develop and test your program.

Problem description: A limited number of tickets for the Hoops championship basketball game go on sale tomorrow, and ticket orders are to be filled in the order in which they are received. There is no limit on the number of tickets that each person can order. No further orders will be taken once no tickets are available. Once the order exceeds the total number of available tickets left, it is automatically adjusted to the number of available tickets and no more orders will be taken. For example, when there are only 2 tickets left and the next order is for 3 tickets, then the order is changed to 2. Write a program that a box-office cashier can use to enter the names and addresses of the persons ordering tickets together with the number of tickets requested, and store this information in a list. The program should then produce a sequence of mailing labels (names, addresses, and number of tickets) for orders that can be filled.

Input: The input should be read from a text file that contains a list of orders including the name, address, and number of tickets requested. The total number of tickets to be sold is read from the keyboard after the input file is read. Each order is written in 3 lines, with the first containing the name, the second the address, and the third number of tickets requested. Orders are separated by a blank line. For example:

Hong Lin

1 Main Street, Houston, TX 77002

3

 

William Sherk

234 Oakridge Drive, Dallas, TX 76023

2

...    // Other orders

Output: The program should print out to the screen the total number of tickets first, and then print out the orders that are taken. Each order should be printed in the same way as it appear in the input file, viz., in 3 lines containing name, address, and number of tickets requested. After each order, the program should print the number of currently available tickets after the previous orders have been taken. The program keeps processing the orders until either all the orders have been processed or there are no more tickets left. The program shouldn't print any orders that cannot be taken.

Requirements on the programming: Use dynamically linked list to store the orders. Your program should firstly read and store all the orders in the input file and then read the total number of tickets from the keyboard. The program then traverses the constructed list to process orders.

Turn-in: A print-out of your program and a disk containing the source code in C++ and the test input file(s).