Electrical and Computer Engineering
4 of 29
UAH
CPE 112
An Example Program
Using Files
•int main()
•{
•    float    htInInches;    // Height of the cone in inches
•    float    diamInInches;  // Diameter of base of cone in inches
•    float    redPrice;      // Price per square foot of red paint
•    float    bluePrice;     // Price per square foot of blue paint
•    float    greenPrice;    // Price per square foot of green paint
•    float    heightInFt;    // Height of the cone in feet
•    float    diamInFt;      // Diameter of the cone in feet
•    float    radius;        // Radius of the cone in feet
•    float    surfaceArea;   // Surface area in square feet
•    float    redCost;       // Cost to paint a cone red
•    float    blueCost;      // Cost to paint a cone blue
•    float    greenCost;     // Cost to paint a cone green
•    ifstream inData;        // Holds cone size and paint prices
•    ofstream outData;       // Holds paint costs
•