CPSC 120A -- Assignment #1
Humanitarian Aid Shipment
Due Friday, September 18, 2009 by 4 p.m.
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 by 40 feet by 12 feet.
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).
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
appropriately labeled):
- 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
Shipment Summary
****************
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).
Requirements:
- You must use meaningful names for variables, constants, and
your class. Use Java conventions for case -- constants (declared
with final) are all uppercase (with the underscore separating words),
variables start with a lowercase letter (but each separate word
within the variable starts with a capital), the class name is
capitalized.
Choosing meaningful names makes your program easier to read and follow.
- You must use constant identifiers where appropriate (there are
several constants in the program).
- Use white space (blank lines and blank spaces) in your program to make
it easier to read. Separate the sections of the program with blank lines.
Indent and align your code properly (emacs helps you do this - it automatically
indents in most cases -- if a line isn't indented correctly go to it
and press TAB OR select the whole program using CTRL-x, CTRL-p then
use ALT-CTRL-\. If TAB doesn't make it indent correctly you probably have
a syntax error).
- Document your program. At the top you must have documentation that
includes the file name, a brief description of
what the program does (this MUST include a list of the input expected
and the output the program will produce), the date, and your name.
Use inline documentation to document each major section of code. However,
don't document every line!!
- Hand In: A printed copy of your program (the source code).
- E-mail: Your source code
to ingram@roanoke.edu.
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.