Assignment 10 Due Mon Nov 28 traffic cones Modify the previo

Assignment 10 Due: Mon, Nov 28 traffic cones Modify the previous cone that computes the cost of painting a file. from given the all of which are variable you use the file stream identifier as ir it were a of file Do the same for the output show the output as reading or a writing Hard copy of output should files module and writing errors in addition to the and code each so that it is divided into modules Modify the PEogram diameter to feet (call function as follow function to coevert dimensions height and the create a void calculate and return d calesurrArea, to create another and blue painting cost. face area to caller to compute the red. sereen and calls create a third void function results to the definitions fourth to output Make sure you choose the right types of parametera for these include Kiostrean and setprecision include kiomanip sqrt tinclude For file I/O include ofst using namespace stda Inches in circumference to diameter Ratio of const float INCHES PER FT 12.01 const float PI 3.14159265 use appropriate paraneters void convert Dimensions cal csurfArea void computecost float void print Results (float, float int main Height of the cone in inches float height base of cone in inches float di Inches Diameter of paint r Price Price per square foot of red Price per square of blue paint foot of b Price float g Price float Radius of the cone in feet radius float surface Area; surface area in square feet float cost to paint a cone red float red Cost: Cost to paint a cone blue bluecosti float Cost to paint a cone green greenCost float Holds cone size and paint prices ifstream inData: Set up floating-pt. cout

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

 Assignment 10 Due: Mon, Nov 28 traffic cones Modify the previous cone that computes the cost of painting a file. from given the all of which are variable you u
 Assignment 10 Due: Mon, Nov 28 traffic cones Modify the previous cone that computes the cost of painting a file. from given the all of which are variable you u

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site