Answered step by step
Verified Expert Solution
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 enqueuecode time, numPeople
and parameters of dequeue to dequeuenumPeople 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
P
B
P
B
P
P
B
B
P
B
B
Here is the structure of BusStop and NodeType:
struct BusStop
char code;
int arrivaltime;
int NumPeople;
;
struct NodeType
BusStop busStop;
NodeType next;
;
Sample Output:
Time PEOPLE ARRIVE, PEOPLE NOW IN LINE.
Time PEOPLE ARRIVE, PEOPLE NOW IN LINE.
Time BUS ARRIVES, PICKS UP REMAIN.
Time PEOPLE ARRIVE, PEOPLE NOW IN LINE.
Time BUS ARRIVES, PICKS UP REMAIN.
Time PEOPLE ARRIVE, PEOPLE NOW IN LINE.
Time PEOPLE ARRIVE, PEOPLE NOW IN LINE.
Time BUS ARRIVES, PICKS UP REMAIN.
Time BUS ARRIVES, PICKS UP REMAIN.
Time PEOPLE ARRIVE, PEOPLE NOW IN LINE.
Time BUS ARRIVES, PICKS UP REMAIN.
Bus stop records complete.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started