The following is a program that involves functions. There is absolutely nobody in my CoSc class that can figure it out. I have written out the entire assignment below.
Assume that before the "red LIght" camera was installed at the corner of Cold Spring Lane and Hillen Rd, there were the following conditions:
1) Traveling along Cold Spring Lane, from 5 to 20 cars arrive at the intersection every 15 seconds.
2) Traveling along Hillen Rd, some 10 to 30 cars reach the intersectin each 15 seconds.
3) The Cold Spring Lane cars each take 0.9 seconds to cross the intersection.
4) On Hillen Road, which has been optimized, cars take .4 seconds to cross the intersection.
5) A car making a left turn prevents 3 cars behind it from crossing the intersection, but fortunately, only 1 car in 20 turns left.
6) The entire red/green cycle takes 90 seconds. Ignore the yellow light.
7) The signals can be switched in 5 second intervals (i.e. red 5 seconds and green 85; red 10 seconds and green 80)
Write a well-documented C++ program that simulates the traffic intersection and determines the timing of red and green lights that interferes least with the traffic flow. Use functions, including the random number generator, to do most of te work. main() should contain only data declarations and function calls. Use the random number generator to determine the number of cars arriving on both streets at the itersection. Other functions should determine the various traffic flow scenerios. Print out the conditions at the intersection every 90 seconds the number of cars that successfully made it throught and the number of cars still waiting on bothe streets. Also, print out the timing interval used.
Run the simulation for each of the signal interval settings in #7 above for twelve minutes each. Which setting inflicts the least waiting time on the motorists?