Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C + + Please adjust parameters of enqueue to enqueue ( code , time, numPeople ) and parameters of dequeue to dequeue ( numPeople )

C++
Please adjust parameters of enqueue to enqueue(code, time, numPeople)
and parameters of dequeue to dequeue(numPeople). Thank you
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 text file:
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

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

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago