Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. Road construction. downtown renovations has lead to temporary closure of Main

ID: 3651997 • Letter: #

Question

. Road construction. downtown renovations has lead to temporary closure of Main Street. Only one lane remains open. The width of the lane is 10 meters and the length of the construction zone is 100 meters. The cars going in the opposite directions have to coordinate their movement. Besides, the students from the university need to cross the street as well. All this created quite an inconvenience for everybody. Ohio Department of Transportation installed temporary traffic lights on both sides of the one-lane section of the street and by the pedestrian crosswalk. ODOT also hired you to write a program to coordinate the work of the traffic lights according to the following rules:

neither car nor pedestrians should wait if the intersection is empty;
cars cannot go in the opposite directions simultaneously on the one-lane section;
a pedestrian cannot cross the street while there is a car in the one-lane section, but multiple pedestrians can cross the street at the same time;
a car may enter the one lane section if there is a car there going in the same direction, however, a car is not allowed to pass another car;
a car does not wait for more than two cars going in the opposite direction;
a pedestrian has to yield to cars BUT a pedestrian should not wait for more than two cars (in either direction).

Write a program constructionzone that coordinates the traffic in the construction zone. Your program should read a file called traffic.txt which contains the information about the traffic arriving at the construction zone. The example file is as follows

0 E1 10
1 P1 1
4 E2 15
5 W1 10

The file has the following format. Each line corresponds to either car or pedestrian. Each entry is a space separated list of three fields. First entry

Explanation / Answer

#include #include #include ftraffic.txt void main(); {traffic.txt}; long 0 E1 10,1 P1 1,4 E2 15,5 W1 10; \ here E1 entering construction E2 entering construction E1 exiting construction E2 exiting construction P1 entering construction P2 exiting construction W1 entering construction W1 exiting construction { - - - - - - - - Printf("E1 entering construction E2 entering construction E1 exiting construction E2 exiting construction P1 entering construction P2 exiting construction W1 entering construction W1 exiting construction"); - - } getch();