Thread: FUNCTIONS...ahhhhh!!!

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    4

    Angry FUNCTIONS...ahhhhh!!!

    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.

    Problem:
    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)

    Assignment:
    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?

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    The functions you need are probably not all that difficult. The problem is figuring out the algorhythm to use first. Forget about writing code to begin. Set things up so you can work start solving the problem with pencil and paper. Then convert the algorhythm to code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM