CSPC 120B Assignment #2
Due Friday, September 21, by 4:00 p.m.
Problem
Your friend is going into the landscape business and specializes in
building circular gardens surrounded by morterless brick walks.
He wants you to
write a program that will help him estimate the materials needed to
build a walk. He gives you the following information:
- it takes six bricks to cover a square foot
- the bricks are sold in straps (cases) of 75
- the walk requires six inches of sand under the bricks.
- sand is sold by the pound and a cubic foot of sand weighs about
130 pounds.
Your program should take as input the diameter of the garden
and the width of the walk and print out the area of the walk
and the quantity of bricks and
sand needed. See below for details on input and output.
Input and Output
Your program should prompt the user for the following input:
- The diameter of the garden in feet and inches (two separate integer
values). Note that this is also the
inner diameter of the walk.
- The width of the walk in feet and inches (two separate integer
values).
Provide the following information as output:
- The information that was input, for completeness.
- The total area of the walk.
- The number of whole straps needed, and the number of additional
bricks needed. These should both be integers.
- The number of pounds of sand needed.
All of this should be nicely formatted and labeled. For example,
your output might look like this:
Garden size: 12 feet, 3 inches in diameter
Walk width: 3 feet, 3 inches
Total area of the walk: 158.2577 square feet
Materials needed:
Bricks: 12 straps plus 50 additional bricks
Sand: 10286.75 pounds
Program Requirements
Store the dimensions that
the user inputs in integer variables -- the user is providing whole numbers
of feet and inches. However, your calculations
should be as precise as possible, using floating point (double) values
and variables as appropriate to store calculated values.
Note that the number of straps and the number of additional bricks
should be integers. Minimize the use of literal values in
your program; in most cases you should use named constants instead.
Your program must include documentation at the beginning
that first gives a
description of purpose of the program, then gives your name (using the @author
tag). Also include comments before the main method as we have in
lab. Be sure to choose good names for
variables and constants.
Follow the capitalization conventions for variables and
constants discussed in class (and in the textbook).
Your code
should fall into logical sections (e.g., input/several groups of
calculations/output), with each section introduced by an explanatory
comment (using the // comment style).
After planning your program (drawing a diagram will help!), do the following:
- Launch Eclipse
- Highlight the Assignments project in the workbench
- Create a new package named assign2. (WARNING: Points
will be deducted if you do not name your package assign2!)
- Create a new class within the package for your source code - don't
forget to check the option to include the "main" stub.
What to Turn In
Turn in hardcopy of your program printed from Linux using the
print script created in lab 2
(in other words it must be in the two column format
with the "Gaudy" header). E-mail the source code to
hughes@roanoke.edu. Put cpsc120 assign2 in the subject line.
Academic Integrity Reminder!!! 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.