CPSC 120A Fall 2002
Program 1: Bricking a Walk
Due Friday, September 20
Problem
With free time on their hands now that you have left for college, your
parents have decided to beautify their back yard by constructing a
circular garden
surrounded by a brick walk. They have not decided
how big the circle should be, or how wide the walk, as they are concerned
about the cost of materials. They know that it takes five bricks to
cover a square foot,and that bricks are sold in straps (cases) of
100. They have a few old bricks lying around, and would like to use
them if possible.
They plan to construct a mortarless walk, which
requires six inches
of sand under the bricks.
Sand is sold by the pound, and a cubic foot of sand weighs about
130 pounds.
You have offered to help them out
by writing a program that takes the diameter of the garden
and the width of the walk and prints 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, to one decimal place.
- The number of whole straps needed, and the number of additional
bricks needed.(Your parents are hoping to use up their extra bricks
if it's just a little over.) These should both be integers.
- The number of pounds of sand needed, to one decimal place.
All of this should be nicely formatted and labeled. For example,
for a garden 10'8" in diameter and a walk 3'2" wide, your output
might look like this:
Your garden is 10 feet, 8 inches in diameter.
Your walk is 3 feet, 2 inches wide.
The total area is 137.6 square feet.
Materials needed:
Bricks: 6 straps plus 89 additional bricks
Sand: 8945.2 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. Minimize the use of literal values in
your program; in most cases you should use named constants instead.
Documentation
Provide a program header that gives your name, the name of the
file, and a description of the program. Use good names for
variables and constants, and use an explanatory comment whenever
a variable's function is not clear from its name.
Follow the capitalization conventions discussed in class.
Your code
should fall into logical sections (e.g., input/several groups of
calculations/output), with each section introduced by an explanatory
comment.
What to Turn In
Turn in hardcopy of your program and e-mail the source code to
bloss@roanoke.edu. Put cpsc120 prog1 in the subject line.
Both the hardcopy and the e-mail are due by 4:00 on the
date above.