Homework help

I am having trouble with this program. For homework we are supposed to write a program that will reads user input in Fahrenheit, converts it to celcius, then puts that data in a file with a list and average. We should have the program, then a file (temps.dat) with a nice table in it that is supposed to look like this.

fahrenheit centigrade
86.0 30.0
91.0 32.8
87.4 30.8
100.3 37.9
98.6 37.0
77.9 25.0
83.7 28.7

average 89.1 31.7

Here is the code I have so far

# include <iostream>
# include <iomanip>
# include <fstream>
using namespace std;

int main (void)
{
float fahr;
ofstream fout, cent;

fout.open("temps.dat");
fout<<setw(25)<<"fahrenheit"<<setw(20)<<"centigrade"<<endl<<endl;

cout <<"Please enter a fahrenheit temperature. Enter -9999 to quit."<<endl;
cin >>fahr;

while(fahr!=-9999)
{cent=(5.0/9.0)*(fahr-32);
count++;
cout<<cent,fahr<<endl;
cin>>farh;

}

fout.setf (ios::fixed);
fout.setf (ios::showpoint);
fout.precision (1);
}



Can anybody help me finish this please? I would greatly appreciate it. I am just stumped at what to do next or how to fix it.
Please use code tags.
You haven't declared cent or count anywhere in the code.
You have a type where you have typed 'farh' instead of 'fahr'. I would give you a line number, but you didn't use code tags...
cent = (5.0/9.0) If you want to do floating point arithmetic, you need to specify that, like this. 5.0f/9.0f

When you have fixed these errors, you need to read in each value from the file, total them and divide by the number of elements and store that average in the file. Each time the user enters a new number, you need to recalculate this.
Topic archived. No new replies allowed.