CPSC 120B -- Assignment #1
Landscape Cost Estimator
Due Friday, September 24, 2004 by 4 p.m.
Your friend is going into the landscape business and wants help
in estimating the materials, cost, and time needed to build stone
retaining walls and steps for customers.
You volunteer to put your newly acquired
programming skills to work and write a Java program to do the
calculations.
Your friend gives you the following information:
- He uses natural stones for the project. He purchases the stones
for the wall by the ton, but the stones for the steps are specially
cut and purchased separately.
- The stones
vary slightly in size but the average is 14 inches wide by 8 inches high.
- The stones for the walls cost $96.50 per ton; the stones for the
steps are $4.75 each.
- An average wall stone weighs 50 pounds. (Recall: There are 2000 pounds
in a ton.)
- The stones are not cut so the actual length or height of the
wall (or steps)
may be slightly different from what the customer requests. For
example, if the customer requests a wall that is 2.75 feet high,
the wall would be made 4 stones high (which would be 32 inches or
2.6667 feet high). On the other hand if the customer requests a
wall that is 4.25 feet high, the wall would be made 7 stones high
which is 4.66667 feet high).
In general, your friend's rule is that if the exact number of
stones needed (for either the height or length of the wall) has
a fractional part less than .35 he uses the smaller number of stones;
otherwise the larger number. For example, in the first example above,
the "exact" number of stones needed for a wall 2.75 feet high would be
4.125. Since .125 is less than .35, the whole part 4 used. In the
second example, the exact number of stones is 6.375 so a height of
7 stones is used. (NOTE: For simplicity, we are are not including
mortar or any material that would be between the stones in these
calculations.)
(NOTE #2: Think about how to do this calculation involving what we
have learned so far. Don't use concepts (such as an if statement)
that we haven't learned yet!)
- The number of stones used for a step is determined by the width
of the step in a similar way to the above. For example, if the customer
wants steps 3 feet wide, the "exact" number of stones needed would
be 2.57... so 3 stones would be used per step. However, if the customer wants
steps 2.5 feet wide, the "exact" number would be 2.142... so 2 stones
would be used per step.
- Extra materials associated with the project cost 75% of
the total stone cost.
- The time it takes to build the steps is about 2.25 hours
per stone needed. About 2.5 square feet of wall
can be built in an hour. To break the time for the project down
into weeks, days, and hours assume work is done
8 hour days and 5 day weeks.
- The cost of labor is $22.50 per hour.
For each job, the customer
specifies the length of the wall (in feet), the minimum height of
the wall (also in feet), the width of each step (in feet), and the number of
steps. Hence the input will be these four quantities.
Output Your friend wants the following information computed
and printed out in a
nice easy to read format with all values labeled appropriately
(similar to that below but you should choose
your own way of formatting).
- The input values (for completeness)
- The number of stones needed for the walls.
- The number of stones needed for the steps.
- The number of tons of stones he needs to buy for the walls.
(This is a whole number; he can't buy part of a ton.)
- The number of stones that would be left over.
- The total cost of the stones.
- The cost of additional materials needed.
- The total cost of labor.
- The total cost of the project.
- An estimate of the amount of time it will take to complete the
project (in weeks, days, and hours).
Sample Output Suppose the customer wants a wall 20 feet in length
by 4 feet high and needs 4 steps each 3.5 feet wide.
Project Specifications:
A 20 foot retaining wall 4 feet high with 4 steps each 3.5 feet wide.
Material, Cost, and Time Estimates:
Number of stones for the wall: 102
Number of stones for the steps: 12
Number of tons of wall stones: 3
Number of wall stones left over: 18
Total cost of stones: $ 346.50
Cost of Miscellaneous materials: $ 259.88
Cost of Labor: $1,327.50
TOTAL: $1,933.88
Estimated Time: 1 week, 2 days, and 3 hours
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).
- Choose the appropriate type for each variable; if a variable
will always hold a whole number, it should be an int.
However, be sure that your calculations
are as precise as possible, using floating point (double) values
and variables as appropriate.
- 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.