Your program should:
Display a welcome message
Ask the user for the metro ID number
Ask the user for 5 different station names
At each station, using a random number generator (explanation on how to do this on page 4 of this handout) generate the number of people who will disembark the train, and the number of people who are waiting to embark on the train. Remember:
1 If the metro train is at the 1st station in any given direction, there will only be people waiting to get on as the train is empty.
2 If the metro train is at the last station, all passengers must get off and no one can get on until the train turns around.
3 Any other station, there are people waiting to get on (a max of 300), and some people will get off the train (can’t have more people getting off than there are people on the train).
4 If the number of places available on the train, after people leave is less than the number of people waiting to get on, some people will be left waiting on the platform for the next train.
Display the number of people who got off the train, who got on the train, and are left waiting on the platform, and how many people are on the metro before it departs for the next station. Include the station name and metro train id.
Ask the user if they would like to continue following the metro
1 If yes, continue to next station and repeat the process
2 If no, end with a closing message.
Now, I don't want anyone to give me the answer but I do have 2 questions.
(1) How do I ensure that the random number generator does not give me numbers that produce a negative value? We never covered RNG in class.
(2) I think I understand how to code the algorithm for stations 2-4, however, I am stumped as to how to start with the first one and making the last one become the first one again (I hope that makes sense).
This post has been edited by ZenOne: 12 October 2013 - 08:37 AM