CAN ANYBODY TELL ME Y MY LAST TABLE IS MESSED UP

# include <iostream>
# include <ctime>
# include <cmath>
# include <iomanip>
# include <fstream>
# include <cstdlib>
using namespace std;
int main()
{
ifstream input ("INFO.DAT");
ifstream takein ("BAR.DAT");
//ofstream output ("TOTAL.OUT");

double alllength, allweight;
double bar_data [20][3];
double bar_used [10][2];
double size[4],diameter[4],length[4],total[4];
int i,j,m,n,numrows;


cout <<"Size Weight Diameter (in)"<<endl<<endl;

for (i=0;!input.eof();i++)
{
for (j=0;j<3;j++)

input>>bar_data[i][j];
}
cout <<setprecision(4);
numrows = i-1;
for (i=0;i<numrows; i++)
{
for (j=0;j<3;j++)

cout <<setw(5)<<bar_data[i][j]<<" ";
cout <<endl;
}
for (m=0;m<4;m++)
{
for (n=0;n<2;n++)
takein>>bar_used[m][n];
}


cout<<endl<<endl;
cout<<"Size Length (ft)"<<endl<<endl;


for (m=0;m<4;m++)
{
for (n=0;n<2;n++)

cout<<setw(5)<<bar_used[m][n]<<" ";
cout <<endl;
}
for (i=0;i<numrows;i++)
for (j=0;j<3;j++)
for (m=0;m<4;m++)
for (n=0;n<2;n++)
if (bar_data[i][0] == bar_used[m][0])
{
size[m] =bar_used[m][0];
diameter[m] =bar_data[i][2];
length[m] =bar_used[m][1];
total[m] =bar_data[i][1] * bar_used[m][1];
}

cout<<endl<<endl;

cout<<"Size Diameter (in) Length (ft) Weight (lb)"<<endl;

for (m=0;m<4;m++)
{
allweight +=total[m];
alllength +=length[m];

cout<<endl;
cout<<setw(5)<<size[m]<<" "<<setw(5)<<diameter[m]<<" "<<setw(15)<<
length[m]<<" "<<total[m];
cout<<endl<<setw(30)<<alllength<<" "<<setw(40)<<allweight;
cout <<endl;
}
system("pause");
}
info.dat
2 .167 .250
3 .376 .375
4 .668 .500
5 1.043 .625
6 1.502 .750
7 2.044 .875
8 2.670 1.000
9 3.400 1.128
10 4.303 1.270
11 5.313 1.410
14 7.650 1.693
18 13.600 2.257
BAR.DAT
4 5000.0
10 2000.0
14 1200.0
18 900.0
Topic archived. No new replies allowed.