Now that you have a working implementation of the Heap class, you will convert it to a template. In this assignment we will create and process a heap of Customer objects. You are encouraged to reuse as much code as possible from previous assignments/labs. The assignment consists of the following classes/files: - Customer.cpp (incomplete) - Customer.h (incomplete) - Heap.h (template, incomplete) - main.cpp (incomplete) Project: An airline company uses the formula shown below to determine the priority of the passengers on the waiting list for overbooked flights. Priority number = A / 1000 + B – C Where - A is the customer’s total mileage in the past year - B is the customer’s number of years in the flier program - C is the sequence number representing the customer’s arrival position when the flight was booked (the first customer’s sequence number is 1, second in the file is 2, and so on). Two or more customers could have the same priority number. For instance, Robert Hill and Tom Martin have the same priority number: Robert Hill’s priority number: 53000 / 1000 + 5 – 1 = 57 Tom Martin’s priority number: 56000/1000 + 5 – 4 = 57 Customers with the same priority number must be served on a first come first serve basis, therefore build the heap based on a unique serial number determined using the following formula: serial number = priority * 100 + (100 – C) In the above example: Robert Hill’s serial number is: 57 * 100 + (100 – 1) = 5799 Tom Martin’s serial number is: 57 * 100 + (100 – 4) = 5796 Given a file with overbooked customers, write a program that reads the file and determines each customer’s priority number, serial number, and prints a list of waiting customers in priority sequence, including the total number of customers served/rejected. There are two types of lines in the input file: line that begins with 'A' or 'S': - the letter 'A' represents the arrival of a new customer and it is followed by: - the number of years in the frequent flier program, - total mileage in the past year, and the - name of the customer (see below). A 5 53000 Robert Hill // insert into the heap A 3 89000 Amanda Trapp // insert into the heap A 3 90000 Jonathan Nguyen // insert into the heap S // delete from the heap and print A 5 56000 Tom Martin // insert into the heap The letter 'S' stands for "Serve" and indicates that the next customer from the waiting list will be served (in priority sequence). Finally, display the overbooked customers that did not get a plain ticket. For each overbooked customer display the number of years in the frequent flier program, total mileage in the past year, the serial number within (), and the name of the customer within [], as shown in the following example. Example: Input file name: 3 89000 (9098) [Amanda Trapp] Served overbooked customers: 1 3 90000 (9097) [Jonathan Nguyen] 5 53000 (5799) [Robert Hill] 5 56000 (5796) [Tom Martin] Rejected overbooked customers: 3
31 lines
472 B
Plaintext
31 lines
472 B
Plaintext
A 5 53000 Robert Hill
|
|
A 3 89000 Amanda Trapp
|
|
A 3 90000 Jonathan Nguyen
|
|
A 5 56000 Tom Martin
|
|
A 1 21000 Mary Lou Gilley
|
|
S
|
|
S
|
|
S
|
|
A 3 89000 Bob Che
|
|
A 7 72000 Warren Rexroad
|
|
A 2 65000 Vincent Gonzales
|
|
A 3 34000 Paula Hung
|
|
S
|
|
S
|
|
A 6 21000 Lou Masson
|
|
A 4 42000 Steve Chu
|
|
A 3 99000 Linda Lee
|
|
S
|
|
S
|
|
A 3 69000 Dave Lightfoot
|
|
A 3 83000 Daniel Oh
|
|
A 5 50000 Sue Andrews
|
|
A 2 73000 Joanne Brown
|
|
S
|
|
A 7 96000 Paul Ng
|
|
S
|
|
A 5 53000 Steven Chen
|
|
A 2 65000 Vladimir Johnson
|
|
S
|
|
A 7 72000 Peter Edwards
|