 ```// This is a function that computes the average wind direction per day
// Created by Emily Wekback and Julian Salai  2/8/00

//includes libararies
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>

void wind_direction(ofstream outfile)
{
float
jday,
tmp,
temp,
pressure,
ws,
wd,
wd_average,
wd_sum,
loop_count;
int day,
error_count,
zero_count,
non_error;
ifstream
input;
ofstream
output;

day = 0;

//opens up input and output files
input.open("89381099.txt");

outfile << "\n\n\n";
outfile << setw(5) << "Day" << setw(17) << "Error Number" << setw(19) << "Wind Direction" << setw(28) << "Average Wind Direction" << endl;
outfile << setw(5) << "---" << setw(17) << "------------" << setw(19) << "--------------" << setw(28) << "----------------------" << endl;

input.ignore(440, '\n');
input.ignore(440, '\n');
input >> jday;

while(input)
{
//reassigns all the identifiers values
loop_count = 1;
wd_average = 0;
wd_sum = 0;
error_count = 0;
non_error = 0;

//loops as long loop_count is less than or equal to 144
while(loop_count <= 144)
{
input >> tmp >> temp >> pressure >> ws >> wd;

input.ignore(30, '\n');

if(ws != 0.0)
{

if(wd == 444.0)
error_count ++;
else

wd_sum = wd_sum + wd;
}
else
zero_count ++;

input >> jday;
}//end of inside while loop

non_error = 144 - (error_count + zero_count);
wd_average = wd_sum / non_error;
day ++;

outfile << setw(5) << day << setw(17) << error_count;
outfile << setiosflags(ios::showpoint | ios::fixed);
outfile << setprecision(2);

//if else statemnets
if((wd_average >= 337.5 && wd_average <= 360) || (wd_average >= 0 && wd_average <=22.5))
outfile << setw(19) << "N" << setw(28) << wd_average << endl;
else if(wd_average >= 22.6 && wd_average <= 45.0)
outfile << setw(19) << "NNE" << setw(28) << wd_average << endl;
else if(wd_average >= 28 && wd_average <= 45)
outfile << setw(19) << "NE" << setw(28) << wd_average << endl;
else if(wd_average >= 45.1 && wd_average <= 67.5)
outfile << setw(19) << "ENE" << setw(28) << wd_average << endl;
else if(wd_average >= 67.6 && wd_average <= 90)
outfile << setw(19) << "E" << setw(28) << wd_average << endl;
else if(wd_average >= 90.1 && wd_average <= 112.5)
outfile << setw(19) << "ESE" << setw(28) << wd_average << endl;
else if(wd_average >= 112.6 && wd_average <= 135)
outfile << setw(19) << "SE" << setw(28) << wd_average << endl;
else if(wd_average >= 135.1 && wd_average <= 157.5)
outfile << setw(19) << "SSE" << setw(28) << wd_average << endl;
else if(wd_average >= 157.6 && wd_average <= 180)
outfile << setw(19) << "S" << setw(28) << wd_average << endl;
else if(wd_average >= 180.1 && wd_average <= 202.5)
outfile << setw(19) << "SSW" << setw(28) << wd_average << endl;
else if(wd_average >= 202.6 && wd_average <= 225)
outfile << setw(19) << "SW" << setw(28) << wd_average << endl;
else if(wd_average >= 225.1 && wd_average <= 247.5)
outfile << setw(19) << "WSW" << setw(28) << wd_average << endl;
else if(wd_average >= 247.6 && wd_average <= 270)
outfile << setw(19) << "W" << setw(28) << wd_average << endl;
else if(wd_average >= 270.1 && wd_average <= 292.5)
outfile << setw(19) << "WNW" << setw(28) << wd_average << endl;
else if(wd_average >= 292.6 && wd_average <= 315)
outfile << setw(19) << "NW" << setw(28) << wd_average << endl;
else if(wd_average >= 315.1 && wd_average <= 337.5)
outfile << setw(19) << "NNW" << setw(28) << wd_average << endl;

}  //ends outside loop

}

```