Electrical and Computer Engineering
3 of 29
UAH
CPE 112
An Example Program
Using Files
•//************************************************************
•// ConePaint program
•// This program computes the cost of painting traffic cones in
•// each of three different colors, given the height and diameter
•// of a cone in inches, and the cost per square foot of each of
•// the paints, all of which are input from a file
•//************************************************************
•#include <iostream>
•#include <iomanip>    // For setw() and setprecision()
•#include <cmath>      // For sqrt()
•#include <fstream>    // For file I/O
• 
•using namespace std;
• 
•const float INCHES_PER_FT = 12.0;   // Inches in 1 foot
•const float PI = 3.14159265;        // Ratio of circumference
•                                    //   to diameter