Posted by **ama** on Thursday, February 14, 2013 at 7:33pm.

Problem 3: Baggage

Name your source code file Bags.py.

You will write a program that simulates the actions of luggage handling for a large aircraft.

As bags arrive they are loaded into containers. Each bag has a different weight and each container can hold a maximum amount of weight. When a container has reached its maximum weight capacity, or the next bag in the line will cause it to exceed its weight capacity, or there is no more bags, the container is sent to be loaded into the aircraft.

At the aircraft loading station, containers are unloaded such that the last container which arrives will be the first to be unloaded. The bags in each container are unloaded in the same order as they were loaded, i.e., last on, last off.

Write a program that prompts the user for a filename and the maximum container weight. The file will contain a list of bag weights in the order that the bags arrive. Your program should output to the screen the weights of the bags in the order they are unloaded. Two sample data files, bags25.dat and bags100.dat, are provided for you to test your program.

For example, here are the contents of the file bags25.dat:

16 24 25 3 20 18 7 17 4 15 13 22 2 12 10 5 8 1 11 21 19 6 23 9 14

## Answer This Question

## Related Questions

- Math 6th Grade Level - A baker bought 680,000 oz. of flour and packed the flour ...
- Math - What do you call an angle more than 90 degrees and less than 180 degrees...
- English - What do you use to do your shopping in England? Plastic bags, carrier ...
- Mathematics - A 25kg bags of sugar is to be repack into a smaller bags of 250g ...
- Science - The mass of a baggage loaded truck and the mass of one bag are given...
- math2 - If you have a line plot with a bag of nuts(in pounds) and there is 1/8 ...
- Math. - Ashanti and Maria went to the store to buy snacks for their back to ...
- Math - Students put 2 1/4 pounds of trail mix into bags that each weigh 3/8 ...
- Math - Chad buys peanuts in 2-pound bags. He repackages them into bags that hold...
- statistics - M&M’s The candy company claims that 10% of the M&M’s it produces ...

More Related Questions