HI all;
i'm a new in c++ programing and i have some problem that i don't know how to fix it. i have been trying to fix it for severaldays and i it isn't working.
can u help me please.
this is my program which is A file contains 7 numbers per line and there are 8 lines and contains several records. i have to Write a program to input each of the numbers, find the highest number, the lowest number, their total and average. Output the numbers, the highest ,lowest , total and average for each set of 7 numbers to another file.
her is my program in c++;
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
int lowest=0, highest=0, sum=0, num=0, row=0;
int average=0, col=0, newline=0,x=0, y=0;
int input_number=0;
ifstream infile;
ofstream outputfile;
infile.open("f:\\input.txt");
outputfile.open("f:\\output.txt");
if(!infile)
{
cout<<"cannot open the input file."<<endl;
outputfile<<"cannot open the input file."<<endl;
return 0;
}
while (!infile.eof())
{
infile>>input_number;
cout<< input_number<<"\t";
outputfile<< input_number<<"\t";
sum = input_number + sum;
newline++;
for(row=1; row<=7; row++)
{
for(col=1;col<=8;col++)
{
if(newline>=6)
{
do
{
x=input_number;
infile>>input_number;
y=input_number;
if(x>y)
highest=x;
else
highest=y;
if(x<y)
lowest=x;
else
lowest=y;
}while (newline==7);
cout<< input_number<<"\t";
outputfile<< input_number<<"\t";
sum = input_number + sum;
newline++;
cout<<endl;
cout<<"The sum is: "<<sum<<endl;
outputfile<<"The sum is: "<<sum<<endl;
average = sum/ newline;
cout<<"The average is: "<<average<<endl;
outputfile<<"The average is: "<<average<<endl;
cout<<"The highest is: "<<highest<<endl;
outputfile<<"The highest is: "<<highest<<endl;
cout<<"The lowest is: "<<lowest;
outputfile<<"The lowest is: "<<lowest;
cout<<endl<<endl;
newline=0;
sum=0;
}
}
}
outputfile<<endl;
}
infile.close();
outputfile.close();
return 0;
}
Please help me i need ur help