CPSC 120 -- Assignment #1
Humanitarian Aid Shipment
Write a Java program to help a local service organization plan a
shipment of food to a war torn country. The organization wants
to send one shipping container of a single commodity (such as wheat, maize, or
dried milk). The shipping container is 9.5 feet wide by 40 feet long by
12 feet high.
The commodity will be packaged in boxes which are different sizes
depending on what is being shipped. The cost of a shipment
depends on the number of boxes that must be loaded into the container
and the weight (in pounds) of the goods to be shipped. The shipping
company the organization plans to use charges $12.75 per box and $0.65
per pound for each pound in excess of 5000 pounds (so if the shipment
weighed 15000 pounds the organization would be charged $0.65 per pound
for 10000 pounds).
Due Friday, September 18, 2009 by 4 p.m.
The program should compute the number of boxes that will fit in the
container and the total cost of shipping the boxes. Furthermore
the organization would like for the program to compute the amount
of aid the shipment would supply in two ways: (1) the total
number of people the shipment would feed for one day; (2) how long
(expressed as months, weeks, and days) the shipment would
feed a village of 150 people.
Input to the program will be:
- the dimensions (width, length, height) of a box (in inches)
- the weight (in pounds) of one cubic foot of the item to be shipped
- the weight (in pounds) that would feed one person for one day
Output Your output must
be nicely formatted (similar to that below but you should choose
your own way of formatting) and must include the following information (all
- The size of a box (in inches) -- this is a repeat of the input
- The total number of boxes that will fit in a shipping container
- The total number of cubic feet in the shipment
- The total weight (in pounds) of the shipment
- The total cost of the shipment
- The number of people the shipment would feed for one day
- How long (expressed as months, weeks, and days) the shipment
would feed a village of 150 people.
Assumptions: Your calculations should be based on the
following assumptions and requirements.
- The boxes must be loaded upright in the container. That is,
the value entered as the height of a box will determine how many
can be stacked up in the container. However, there
would be two possible orientations. For example, if the boxes are
48 inches long by 36 inches wide by 50 inches high they can be
put in the container either with the 48 inch side going the length of
the container or with the 36 inch side going the length of the container.
Your program should compute the number of boxes that fit both
directions and then select the maximum (there is a method in the
Math class to do this).
- In computing the number of months, weeks,
and days assume a month has 30 days.
Sample Output (NOTE: This shows the prompts and input of
24 36 30 for the dimensions
of the box; 7.5 for the weight; 2.5 for the amount to feed one person
for one day.)
Analysis of Shipment of Humanitarian Supplies
Enter size of each box to be shipped ---
width, length, height (in inches): 24 36 30
Enter the weight (in pounds) per cubic foot of the goods: 7.5
Enter the number of pounds needed to feed one person for one day: 2.5
Box size (in inches): 24.0 by 36.0 by 30.0
Number of Boxes: 240
Total Cubic Feet: 3600.0
Weight: 27000.0 pounds
Shipment Cost: $ 17360.00
The shipment will feed 10800 people for one day OR
a village of 150 people for 2 month(s), 1 week(s), and 5 day(s).
Academic Integrity Reminder!!! Programming
assignments are to be your own work. You may get help on the specifics
of the assignment from no one except the instructor. You may not show
your program to anyone or look at anyone else's program or share ideas
with anyone about how to write the program.