Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C + + Please utilize NodeType structure throughout the program, create an enqueue using parameters code, time, numPeople, and create a dequeue using parameter numPeople.

C++
Please utilize NodeType structure throughout the program, create an enqueue using parameters code, time, numPeople, and create a dequeue using parameter numPeople. Please ensure the output of the program matches exactly like the sample output.
Write a program that simulates a waiting line at a bus stop using a queue data structure. Each input
record comprises three elements: code (B for bus arrival, P for people arrival), a time, and a
numPeople representing the number of people for buses. Buses pick up people in the order they arrive,
with each bus departing once it reaches its capacity. When a B record is processed, print: TIME xxx.
BUS ARRIVES, PICKS UP yyy PEOPLE. zzz REMAIN. When a P record is processed, print: TIME xxx. xxx
PEOPLE ARRIVE, xxx PEOPLE NOW IN LINE.
//input.txt
P 090015
P 091015
B 091520
P 092025
B 093050
P 094520
P 095525
B 100530
B 101510
P 103025
B 103530
B 104530
Here is the structure of BusStop and NodeType:
struct BusStop
{
char code;
int arrival_time;
int NumPeople;
};
struct NodeType
{
BusStop busStop;
NodeType* next;
};
Sample Output:
Time 0900.15 PEOPLE ARRIVE, 15 PEOPLE NOW IN LINE.
Time 0910.15 PEOPLE ARRIVE, 30 PEOPLE NOW IN LINE.
Time 0915. BUS ARRIVES, PICKS UP 20.10 REMAIN.
Time 0920.25 PEOPLE ARRIVE, 35 PEOPLE NOW IN LINE.
Time 0930. BUS ARRIVES, PICKS UP 50.0 REMAIN.
Time 0945.20 PEOPLE ARRIVE, 20 PEOPLE NOW IN LINE.
Time 0955.25 PEOPLE ARRIVE, 45 PEOPLE NOW IN LINE.
Time 1005. BUS ARRIVES, PICKS UP 30.15 REMAIN.
Time 1015. BUS ARRIVES, PICKS UP 10.5 REMAIN.
Time 1030.25 PEOPLE ARRIVE, 30 PEOPLE NOW IN LINE.
Time 1035. BUS ARRIVES, PICKS UP 30.0 REMAIN.
Bus stop records complete.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago