#include #include // For setprecision() using namespace std; int main( ) { const double MainArc = 42.3333333, SecondaryArc = 52.25, pi = 3.14159265; ifstream rainbow; // input file stream ofstream heights; // output file stream double distance, // Distance of rainbow heightMain, // 1st Rainbow's height heightSecondary; // Shadow's height /*Testing something int numInput, // Number of data inputs calculated; //Data inputs already calculated calculated = 0; rainbow.open("rainbow.dat"); heights.open("heights.dat"); heights.setf(ios::fixed, ios::floatfield); heights.setf(ios::showpoint); //added code// numInput = 0; string line; ifstream in("rainbow.dat"); while(getline(in, line)) numInput+=1; numInput = numInput + 100; //End Added Code// */ heights << "Larry Titus" << endl; //*** substitute your own name *** heights << "Rainbow Heights (in miles)" << endl << endl; rainbow.ignore(200, '\n'); // Skip to next line of input. heights << " Rainbow Secondary Distance" << endl; heights << "---------------------------------------------" << endl; //if ((rainbow) && (numInput > 0)) if (rainbow) rainbow >> distance; //while ( (rainbow) && (calculated < numInput) ) { while (rainbow) { //calculated++; rainbow.ignore(200, '\n'); // Skip to next line of input. heightMain = distance * tan(MainArc * pi / 180); heightSecondary = distance * tan(SecondaryArc * pi / 180); heights << setw(4) << setprecision(4) << heightMain; heights << setw(13) << setprecision(4) << heightSecondary; heights << setw(14) << setprecision(4) << distance; heights << endl; rainbow >> distance; } heights << "---------------------------------------------"; heights << endl; rainbow.close(); heights.close(); //return calculated; return 1; }