## CPSC 120A -- Assignment #1

### Humanitarian Aid Shipments Due Friday, September 23, 2005 by 4 p.m.

The news of the last several weeks has made it clear that disaster planning and relief is both important and difficult. For this assignment you will write a Java program to help a relief organization plan the shipment of supplies to a disaster area.

The relief agency ships supplies to a disaster area in tractor trailers that measure 48 feet long, 98 inches wide, and 110 inches high on the interior. The agency needs a program that will help them compute the number of trucks needed to supply a certain number of people for a week. They also would like additional information calculated such as the time it would take the trucks to reach the disaster area and the amount of fuel it would take. These values of course depend on things such as what commodity they are shipping, how many people can be supplied by that commodity, and the distance to the disaster area. It is assumed that all items are shipped in rectangular boxes and all boxes in a given shipment are the same size.

The program should meet the following requirements:

Input to the program will be:

• the dimensions (width, length, height) of a box (in inches)
• the number of people that one box would supply for one week
• the number of people who need aid
• the distance to the disaster site (in miles)

Values to compute:

• The number of boxes needed to supply the given number of people for a week.
• The number of boxes that will fit in each truck.
• The total number of trucks needed to supply the given number of people.
• The amount of space extra space (see assumptions below).
• The amount of time (in days and hours) it will take the shipment to arrive at the disaster site.
• The number of gallons of diesel fuel it will take.
Assumptions: Your calculations should be based on the following assumptions and requirements.
• The boxes must be loaded upright in the truck; however, there would be two possible orientations. For example, if the boxes are 48 inches long by 36 inches wide by 54 inches high they can be put in the truck either with the 48 inch side going the length of the truck or with the 36 inch side going the length of the truck. 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).
• Assume all trucks, except possibly one, are filled to capacity. For the one that is left over, compute the amount of space left (in cubic feet).
• To compute the time it takes, assume the average speed over the whole trip is 50 miles per hour. Assume that each truck will have two drivers so they can drive constantly (federal regulations require that a driver can drive no more than 10 hours without an 8 hour rest but in this case one driver can rest while the other drives). The average speed takes into account short breaks. Hence if the distance to the disaster site is 1,320 miles the driving time is 27 hours (it is actually 26.4 but we will go up to the next hour for any fractional part - there is a method in the Math class to do this).
• Assume each truck gets 15 miles to a gallon of diesel fuel.

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 with white space):

• The size of a box (in inches) -- this is a repeat of the input
• The total number of boxes that will fit in a truck
• The total number of trucks needed.
• The number of cubic feet of space left in the truck that is not filled to capacity (if there is one).
• The number of extra boxes that would fit in the left over space.
• How long (expressed as days and hours) it would take the trucks to make the trip. Note: Any fractional hour should go up to the next whole hour (see the assumptions above).

Sample Output (NOTE: This shows the prompts and input of 36 48 54 for the dimensions of the box; 6 for the number of people one box supplies for a week; 2500 for the number of people to feed and 1320 for the distance.

```Analysis of Shipment of Humanitarian Supplies
=============================================

Enter size of each box to be shipped ---
width, length, height (in inches): 36 48 54
Enter the number of people one box supplies for a week: 6
Enter the number of people who need aid: 2500
Enter the distance to the disaster site: 1320

Shipment Summary
****************
Box size (in inches): 36 by 48 by 54
Number of Boxes:
Number of Trucks:
Excess space in the truck that isn't full:   ___ cubic feet
Number of extra boxes that could be taken:
Time to reach the disaster area:   ____ days and ____ hours
Number of gallons of diesel fuel needed:

```

### 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 -- 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 should include a list of the input expected and the output the program will produce), the date, and your name.
• 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.