Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Exercise 3 (Must use linked structure-based Queue) Scenario: You are developing a queue system for Immigration counters at the airport. There are two counters open

Exercise 3 (Must use linked structure-based Queue)

Scenario:

You are developing a queue system for Immigration counters at the airport. There are two counters open at this hour to serve travelers: one for single travelers and one for travelers with families. Each traveler/set of travelers is called an instance of the Family class.

class Family

{

private:

int noOfKids;

int noOfElders ;

int id;

public:

//provide required functions

//Constructors, setter and getters

//overloaded operators such as ==,=,!= .

};

Each Counter is a queue of Family objects. That means, ItemType is Family.

Sample for counters:

Counter 1

Counter 2

Family(100,2,2)

ID=100, elders=2, kids=0

Family(200,2)

ID=100, elders=2, kids=0

Family(400,1)

ID=100, elders=1, kids=0

Family(300,2,1)

ID=300, elders=2, kids=1

Family(500,1,2)

ID=500, elders=1, kids=2

For the aforementioned scenario,

Develop a suitable application level (non-member, non-friend) functions as explained below:

A new counter is opened and you want to move families with more than 3 kids to new counter. Write a function that returns a new queue with corresponding families.

A new counter, counter3 is opened to process the travelers fast. You function should return a new queue after adjusting equal numbers of families in all three queues.

Lets say, counter 1 has 10 families and counter 2 has 8 families. After opening a new counter 3, each counter should have 6 families each.

Another example, counter1 has 12 families and counter 2 has 8. After adding counter 3 counter1 and 2 should have 7 each and counter should accompany 6 families.

Note: Moving the families to other counters should be done from the cutoff point of the queue.

Newly opened counter should be filled by choosing alternate families from existing queues. For example, if existing two counters have 10 families each. New counter should have families in this order- counter1s 8th family, counter2s 8th family, counter1s 9th family, counter2s 9th family, counter1s 10th family and counter2s 10th family.

Write an appropriate Driver to test all above functions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions