Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Font Assignment 02 Due on Sept 28, 2018 The following program computes the cost

ID: 3755194 • Letter: F

Question

Font Assignment 02 Due on Sept 28, 2018 The following program computes the cost of painting traffic cones in three different colors red, blue and green .siven the height and diameter of a cone in inches, and the cost per square foot of each of the paints. // Progra 02LASINAME //ConePaint progras .o inelude // include header tiles needed 3ng nanespace atd int main Declare the Beighe of a typical cone as conatant, give it the value 30 inches Ceclare the dianeter of base of cone as conacant, give it the value 8 inches Deciare RED PRICE, the Prioe per square foot of red paint, as conscant give it the walue 0.10 Declaze BLUT FRICE, tbe Price per square foot of bioe paint, as comstant give GREE RSC, the Price per square toot of Declaze it the value 0. const float PI -3.14159265 oonst zlost green paint, as constant give Ratso of circusterence to disneter Inches in 1 foot rloat heightInFt: float d1anInFt tloat zadius: tlost auztscekrea: tlost redCost // Height of the cone in feet // Dianeter of the cone in feet / Radius of the cone in feet Surtace srea in squaze feet /7Cost to paint a cone red 7 Coat to paint a cone blue / Cost to paist a cone geeen float greencoata eous s7 shovpont:et up floating-pe.ousput s rch 4 5 6 9 R T Y

Explanation / Answer

#include <iostream>
#include <cmath> // for sqrt() function
#include <iomanip> // for setprecision() function
using namespace std;

int main() {

const float heightInFeet = 30;
const float baseDiameter = 8;
const float RED_PRICE = 0.10;
const float BLUE_PRICE = 0.15;
const float GREEN_PRICE = 0.18;

const float PI = 3.14159265;
const float INCHES_PER_FT = 12.0;

float heightInInches = heightInFeet * INCHES_PER_FT; // conversion from feet to inches
float surfaceArea = PI * baseDiameter/2 * sqrt(baseDiameter/2 * baseDiameter/2 + heightInInches*heightInInches);

float redCost = RED_PRICE *surfaceArea;
float blueCost = BLUE_PRICE *surfaceArea;
float greenCost = GREEN_PRICE *surfaceArea;

cout<<fixed<<setprecision(3);

cout<<"Cost of painting red traffic cone : $"<<redCost<<endl;
cout<<"Cost of painting blue traffic cone : $"<<blueCost<<endl;
cout<<"Cost of painting green traffic cone : $"<<greenCost<<endl;

return 0;
}

Output:

Cost of painting red traffic cone : $452.417
Cost of painting blue traffic cone : $678.626
Cost of painting green traffic cone : $814.351

Do ask if any doubt. Please upvote