All pastes #177257 Raw Edit

Novell_Nazi

public cpp v1 · immutable
#177257 ·published 2006-09-20 09:07 UTC
rendered paste body
#include <fstream>#include <iomanip> // For setprecision()using namespace std;int main( ) {const double MainArc = 42.3333333,SecondaryArc = 52.25,pi = 3.14159265;ifstream rainbow; // input file streamofstream heights; // output file streamdouble distance, // Distance of rainbowheightMain, // 1st Rainbow's heightheightSecondary; // Shadow's heightint numInput, // Number of data inputscalculated; //Data inputs already calculatednumInput = 5;calculated = 0;rainbow.open("rainbow.dat");heights.open("heights.dat");heights.setf(ios::fixed, ios::floatfield);heights.setf(ios::showpoint);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)rainbow >> distance;while ( (rainbow) && (calculated < numInput) ) {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) << heightMain;heights << setw(4) << setprecision(4) << heightSecondary;heights << setw(10) << setprecision(4) << distance;heights << endl;rainbow >> distance;}heights << "---------------------------------------------";heights << endl;rainbow.close();heights.close();return calculated;}