Assignment 10 Due Mon Nov 28 traffic cones Modify the previo
Solution
Code:
#include<iostream>
#include<math.h>
 #include<fstream>
using namespace std;
const float INCHES_PER_FT = 12.0;
 const float PI = 3.14159265;
void convertDimensions(float *,float *);
 float calcSurfArea(float,float);
 void computeCost(float *,float *,float *,float,float,float,float);
 void printResults(float,float,float);
int main(){
   
    float height;   // height of the cone in inches.
    float diInches;   //Diameter of base of cone in inches.
    float rPrice;
    float gPrice;
    float bPrice;
    float radius;
    float surfaceArea;
    float redCost;
    float blueCost;
    float greenCost;
    ifstream inData;
   
    cout<<fixed<<showpoint;
    inData.open(\"C:/Users/user/Desktop/chegg/content.txt\");
    if(!inData){
        cout<<\"** can\'t open file\"<<\"**\"<<endl;
        return 1;
    }
    inData>>height>>diInches>>rPrice>>bPrice>>gPrice;
     convertDimensions(&height,&diInches);
    radius = diInches/2;
    surfaceArea = calcSurfArea(height,radius);
    cout<<\"Surface Area : \"<<surfaceArea<<endl;
    computeCost(&redCost,&blueCost,&greenCost,surfaceArea,rPrice,gPrice,bPrice);
     printResults(redCost,greenCost,blueCost);
    return 1;
 }
 void convertDimensions(float *height,float *diInches){
    *height = *height / INCHES_PER_FT;
    *diInches = *diInches / INCHES_PER_FT;
 }
 float calcSurfArea(float h,float r){
    float sArea;
    sArea = (PI * r) * (r + sqrt((h*h))+(r*r));
    return sArea;
 }
 void computeCost(float *redCost,float *blueCost,float *greenCost,float sArea,float rPrice,float gPrice,float bPrice){
    *redCost = sArea * rPrice;
    *greenCost = sArea * gPrice;
    *blueCost = sArea * bPrice;
 }
 void printResults(float redCost,float greenCost,float blueCost){
    cout<<\"Red paint cost : \"<<redCost<<endl;
    cout<<\"Green paint cost : \"<<greenCost<<endl;
    cout<<\"Red paint cost : \"<<blueCost<<endl;
 }
Sample Results:
Input:
45 30 2 4 6
Output:
Surface Area : 25.770878
 Red paint cost : 51.541756
 Green paint cost : 154.625275
 Red paint cost : 103.083511


