0

Hi I'm having a lot of problems with this homework problem due tomorrow.

The assignment is to make a program that can read data from a file and give out the wind chill, average temperature, average air speed, and average wind chill. It must also reject data that has a temperature (in fahrenheit) of larger than 50 or an air speed of larger the 120 mph. I haven't even written any function to calculate the average wind chill because I simply do not know how. There are definitely problems here, but I don't know how to correct or solve them.

An example of some of the data from the file is:

Temp Air speed

32 F 20

2 C 25

If a temperature is in Celsius the program must convert it back to fahrenheit.

Any help is appreciated.

```
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
using namespace std;
ofstream outfile("WindChillOutfile.txt");
ifstream infile("/Users/richiemizrahi/Documents/C++/WindChill/weather.dat");
double Ta, V, Twc;
double WindChill();
double AvgTemp();
double AvgAirSpeed();
int main()
{
double T, Ta, V, Twc;
char scale;
if (!infile.is_open() ) {
cout << endl << "ERROR: Unable to open file" << endl;
exit(1);
}
while (!infile.eof() ) {
infile >> T >> scale >> V;
if(!scale == 'F') {
Ta = (T * 9 / 5) + 32;
}
if( !Ta > 50 || V > 120){
WindChill();
AvgTemp();
AvgAirSpeed();
}else
;
outfile << "The temperature is " << Ta << " F, " << endl;
outfile << "the air speed is " << V << " mph, " << endl;
outfile << "and the wind chill index is " << Twc << " F." << endl;
outfile << endl;
outfile << AvgTemp << endl;
outfile << AvgAirSpeed << endl;
}
return 0;
}
double WindChill()
{
Twc = 35.74 + (0.6215 * Ta) - (35.75 * pow(V,0.16)) + (.4275 * Ta * pow(V,0.16));
}
double AvgTemp()
{
int counter;
float average, number, sum;
counter = 0;
sum = 0;
infile >> number;
while ( !infile.eof() ){
++counter;
sum = sum + number;
infile >> number;
;
infile >> number;
}
average = sum / counter;
outfile << "The average temperature is " << average << " F, " << endl;
}
double AvgAirSpeed()
{
int counter;
float average, number, sum;
counter = 0;
sum = 0;
infile >> number;
while ( !infile.eof() ){
;
infile >> number;
++counter;
sum = sum + number;
infile >> number;
}
average = sum / counter;
outfile << "the average air speed is " << average << " mph, " << endl;
}
```