Question: 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.
inputtxt
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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
