Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Final Machine Problem - Airplane Seating Assignment

CPS171-03 Tuesdays 5:30-9:40pm


Due: December 19, 2017 by 8am
100 points total

Write a program that can be used to assign seats for a commercial airplane for a list of passengers. The
airplane has 12 rows, with four seats in each row. Rows 1 and 2 are First Class, rows; 3, 4 and 5 are Business
Class rows; and rows 6 and higher are Economy.

Your program must do the following:

1. Setup a 12 x 4 two-dimensional array of bool which represent Aircraft seating


2. Create an enumeration called SeatLocn which corresponds to seats location of A, B, C and D across
each row and use that enumeration throughout your program.
3. Create an enumeration called CabinClass which corresponds to seats in First Class, Business Class and
Economy Class and use that enumeration throughout your program.
4. Create a Passenger structure with the following members;
a. string firstName
b. string lastName
c. CabinClass classPref
d. int row
e. SeatLocn seat
5. Read in customer data from Passengers.txt data file into an array (list) of Passenger structures (max
50). Each row contains; First Name, Last Name and Cabin Class (F/B/E). The seat location (A/B/C/D)
and row number are NOT part of each row of data.
6. After loading the data file into the Passengers list, load those passenger requests into the Aircraft and
make seat assignments. Seat assignments are random based on their Class preference
7. Have a function which sorts the Passenger list by last name (A-Z). Call this after each time a Passenger
is added to the list
8. Your program should have a menu which will allow a user to:
a. Add a new passenger and their Cabin Class preference to the list
b. Un-assign a passenger by last name and free the seat up on the Aircraft. Do not delete a
person from the list of Passengers.
c. Pick a person from the list and assign them a seat. If they are already assigned, free up that
seat and make a new assignment.
i. If there are no seats in their preferred Cabin Class available, then ask them if they
want to downgrade or upgrade. If so, then assign according to their preference,
otherwise leave them unassigned
d. Clear the aircraft and un-assign all passengers.
e. Print the Aircraft seating chart.
f. Print the assigned Passenger list (which will be printed in last name order)
g. Quit the program

Menu could look like this:


1 Add New Passenger
2 Un-assign Passenger
3 Assign Seat to existing passenger
4 Clear the Aircraft and seat assignments
5 Print Aircraft Chart
6 Print Passenger List
Q Quit
When you print the Aircraft seating chart, print it like this:

A B C D
Row 1 * * X *
Row 2 * X * X
Row 3 * * X X
Row 4 X * X *
Row 5 * X * X
Row 6 * X * *
Row 7 X * * *
Row 8 * X * X
Row 9 X * X X
Row 10 * X * X
Row 11 * X * X
Row 12 * X * X

* indicates an empty seat


X indicates a filled seat

When you print the Passenger list, print it like this:

Name Preference Row/Seat


Al Johnson First Class 1A
Bob Jones Economy 10A
Fred Masters Business Class 4C
Homer Simpson Economy Unassigned
Tom Smith Economy 11A
Suzy Smith Economy 11B
Sam Snead Business Class 3A

The small sample data file for these passengers is:

Bob Jones E
Tom Smith E
Homer Simpson E
Suzy Smith E
Al Johnson F
Sam Snead B
Fred Masters B

You might also like