Data Abstraction and Structures Lab Heap ADT Project 10.10 Lab: Heap ADT Now that you have a working implementation of the Heap class, you will convert it
Data Abstraction and Structures Lab Heap ADT Project 10.10 Lab: Heap ADT
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. Example:
Input file name: overbooked_2.txt
==== ======= =============
Year Mileage Name
==== ======= =============
3 89000 Amanda Trapp
2 65000 Vincent Gonzales
==== ======= =============
Served overbooked customers: 2
==== ======= =============
Year Mileage Name
==== ======= =============
2 65000 Vladimir Johnson
5 53000 Robert Hill
4 42000 Steve Chu
3 34000 Paula Hung
==== ======= =============
Rejected overbooked customers: 5
We've got everything to become your favourite writing service
Money back guarantee
Your money is safe. Even if we fail to satisfy your expectations, you can always request a refund and get your money back.
Confidentiality
We don’t share your private information with anyone. What happens on our website stays on our website.
Our service is legit
We provide you with a sample paper on the topic you need, and this kind of academic assistance is perfectly legitimate.
Get a plagiarism-free paper
We check every paper with our plagiarism-detection software, so you get a unique paper written for your particular purposes.
We can help with urgent tasks
Need a paper tomorrow? We can write it even while you’re sleeping. Place an order now and get your paper in 8 hours.
Pay a fair price
Our prices depend on urgency. If you want a cheap essay, place your order in advance. Our prices start from $11 per page.