PAINTING
TRAFFIC CONES
Problem: The Hexagrammum Mysticum Company
manufacures a line of traffic cones. The company is preparing to bid on a
project that will require it to paint its cones in different colours. The paint
is applied with a constant thickness. From experience, the firm finds it easier
to estimate the total cost from the area to be painted. The company has hired
you to write a program that will compute the surface area of a cone and the
cost of painting it, given its radius, its height, and the cost per square foot
of three different colours of paint.
Output: The surface area of the
cone in square feet, and the costs of painting the cone in the three different
colours, all displayed in floating point form.
Discussion: From interviewing
the company’s engineers, you learn that the cones are measured in inches . A
typical cone is 30 inches high and 8 inches in diameter. The red paint costs 1-
cents per square foot; the blue costs 15 centsl the green costs 18 cents. In a
math text, you find that the area of a cone (not including its base, which wont
be painted) equals:
(r2+h2) where r is the radius of the cone and h is
its height.
The first thing the program must do is convert the cone measurements into feet an divde the diameter in hlf to get the radius. Then I can apply the formula to get the surface area of the cone. To determine the painting costs, it must multiply the surface area by the cost of each of the three paints. Here’s the algorithm:
Set heightInFeet=
heightInInches/12
Set
diameterInFeet = diameterInInches /12
Set
radius = diameterInFeet/2
Set
surfaceArea = pi*radius*sqrt(radius*radius+heightInFeet*heightInFeet)
Set
redCost =SurfaceArea * .10
Set
blueCost =surfaceArea* .15
Set
greenCost= surfaceArea*.18
Print surfaceArea
Print
redCost
Print
blueCost
Print
greenCost
The output from the program is:
The surface area is
2.641 sq. ft.
The painting cost
for
Red is
.264 dollars
Blue is
.396 dollars
Green is .475 dollars
“Traffic
cones throughout history”