|
|
|
|
|
|
|
Problem-Solving Case Study Painting Traffic Cones |
|
|
|
|
|
|
|
|
Problem: The Hexagrammum Mysticum Company manufactures a line of traffic cones. The company is preparing to bid on a project that will require it to paint its cones in different colors. 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 colors of paint. |
|
|
|
|
|
|
|
|
Output: The surface area of the cone in square feet, and the costs of painting the cone in the three different colors, 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 10 cents per square foot; the blue costs 15 cents; the green costs 18 cents. In a math text, you find that the area of a cone (not including its base, which won't be painted) equals |
|
|
|
|
|
|
|
|
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 and divide the diameter in half to get the radius. Then it 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 + heighInFeet*heightInFeet)
Set redCost = surfaceArea * 0.10
Set blueCost = surfaceArea * 0.15
Set greenCost = surfaceArea * 0.18
Print surfaceArea
Print redCost
Print blueCost
Print greenCost |
|
|
|
|
|