//This is a function that computes dewpoint //Written by Max Indelicato and Adam Plumb #include <iostream.h> #include <fstream.h> #include <math.h> #include <iomanip.h> #include <math.h> void dewpoint(ofstream outfile) { double Spd, T, sum, ten_min, average, JD, pressure, blah; //declares variables as data type double int real_info, bad, loop_count, day;//declares variables as data type int double Td, RH, K, Td2; const double Rv = 461.5; ifstream inputfile; //declares inputfile inputfile.open("89381099.txt"); //opens input text file (varies) inputfile.ignore(500, '\n'); //ignores first line of inputfile inputfile.ignore(500, '\n'); //ignores second line of inputfile day = 1; //initializes day as equaling 1 outfile << "\n\n\n"; outfile << "DAY" << " " << "DEWPOINT" << " " << "# OF ERRORS" << endl; //outputs labels of ouputfile outfile << "------------------------------------------------------------------------------"<> JD; //gets initial Julian Day while(loop_count <= 144) //initiates loop { inputfile >> ten_min >> T >> pressure >> Spd >> blah >> RH; //reading in file inputfile.ignore(500, '\n'); //ignores the rest of the line if(pressure != 444.0 && T != 444.0 && RH != 444.0) //If statement { K = T + 273.15; //computing kelvin Td = ((1/K) - (Rv * log(RH))/(2500800 - 2397.5 * (K - 273.15))); Td2 = pow(Td, -1); sum = sum + Td2; //adding a total real_info++; //counting number of times } else //else statement bad++; loop_count++; //adding 1 to loop_count inputfile >> JD; //reading in JD } //end of inside while loop average = sum / real_info; //gets average outfile << setiosflags(ios::showpoint | ios::fixed); //declaring iosflags outfile << setprecision(5); //sets precision to 2 //outputs data to file outfile << setw(2)<< day << setw(21) << average << setw(25) << bad << endl; //adds one to day day++; } //end of outside while loop }