Advertisement
MORGATRON16

problem

Aug 13th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.28 KB | None | 0 0
  1. Problem
  2. A Codetown city bus can seat 50 passengers. For each route, a bus starts at a particular bus stop and picks up any passengers that are waiting (provided they all fit on the bus - otherwise only the first 50 are picked up). Until the end of the route, the bus repeatedly moves to the next bus stop, dropping off any passengers that wish to get off the bus at that point and picking up any waiting passengers that can fit on the bus (though only 50 passengers can ever be on the bus at any one time).
  3.  
  4. Codetown's council has been receiving complaints that there are frequently not enough seats on the busses for passengers. However, money is tight and the council can only afford to put extra busses on the most popular routes. The problem is that the council has no data to allow them to determine which routes are most popular.
  5.  
  6. Codetown's mayor has asked you to construct a program that can be used by the town's bus drivers to collect the data the council needs. At the start of the program, the driver should be asked the route number, how many stops there are along that route, and the number of passengers at the start of the route. Then, for each remaining stop, the driver should be prompted to enter the number of passengers leaving the bus, and the number of passengers waiting to get on the bus at that stop (though all passengers must leave and no passengers can get on the bus at the last stop at the end of the route). Your program should then output the route number, the total number of passengers that got on the bus ("happy customers"), the total number of passengers that were unable to get on the bus because it was too full ("unhappy customers"), and the ratio of happy customers to unhappy customers (to two decimal places, and set to 0 if there were no unhappy customers).
  7.  
  8. Note: Your program should ensure that the route number is a positive integer, there are at least two stops (the start and end) on the route, and the number of passengers getting on and off the bus at each stop are non-negative integers. You also need to ensure that the number of passengers that want to get off the bus at any stop is not greater than the number of passengers currently on the bus. If this is not the case, you need to prompt the driver to re-enter the information, as it is likely it was a typing mistake.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement