xredawg909x
10-26-2005, 04:26 PM
i got a hw problem for C++ if anyone is kind enough to help with
i gotta write a program that calls different functions that reads in a text file
and calculates data and outputs it back into another textfile
that looks like this:
John Smith 45 45 19
Sue Smith 19 45 20
function one reads in the information and passes it back to main
function two calculates the average of the 3 numbers out of 150
function three outputs it back into another text file
this is what i got so far
void readinfo(inFile&, int&, int&, int&);
float calc(int);
//not sure how to define the prototype for file output
int main()
{
ofstream fout("output.txt");
ifstream fin("John.txt");
int x,a,b,c;
x = readinfo(infFile, a, b, c);
}
void readinfo(ifstream &inFile, int &num1, int &num2, int &num3)
{
inFile>>num1>>num2>>num3;
cout<<fixed precision>>setprecision(2)<<num1+num2+num3/150<<endl;
}
not sure if that will work or how do the rest, any comments hints anyone?
i gotta write a program that calls different functions that reads in a text file
and calculates data and outputs it back into another textfile
that looks like this:
John Smith 45 45 19
Sue Smith 19 45 20
function one reads in the information and passes it back to main
function two calculates the average of the 3 numbers out of 150
function three outputs it back into another text file
this is what i got so far
void readinfo(inFile&, int&, int&, int&);
float calc(int);
//not sure how to define the prototype for file output
int main()
{
ofstream fout("output.txt");
ifstream fin("John.txt");
int x,a,b,c;
x = readinfo(infFile, a, b, c);
}
void readinfo(ifstream &inFile, int &num1, int &num2, int &num3)
{
inFile>>num1>>num2>>num3;
cout<<fixed precision>>setprecision(2)<<num1+num2+num3/150<<endl;
}
not sure if that will work or how do the rest, any comments hints anyone?