RK TEAM YDS YDS/G PASS P YDS/G RUSH R YDS/G PTS PTS/G
1 Philadelphia 4951 412.6 3066 255.5 1885 157.1 271 22.6
2 New Orleans 4946 449.6 3566 324.2 1380 125.5 362 32.9
3 New England 4724 429.5 3510 319.1 1214 110.4 331 30.1
4 Green Bay 4414 401.3 3345 304.1 1069 97.2 382 34.7
5 Carolina 4386 398.7 2898 263.5 1488 135.3 252 22.9
6 Dallas 4291 390.1 2988 271.6 1303 118.5 270 24.5
7 San Diego 4246 386.0 3037 276.1 1209 109.9 249 22.6
8 Houston 4177 379.7 2508 228.0 1669 151.7 293 26.6
9 Detroit 4144 376.7 2997 272.5 1147 104.3 316 28.7
10 Pittsburgh 4120 374.5 2914 264.9 1206 109.6 233 21.2
11 NY Giants 4111 373.7 3206 291.5 905 82.3 252 22.9
12 Oakland 4106 373.3 2465 224.1 1641 149.2 260 23.6
13 Atlanta 4025 365.9 2730 248.2 1295 117.7 259 23.5
14 Buffalo 3800 345.5 2458 223.5 1342 122.0 261 23.7
15 Tampa Bay 3742 340.2 2624 238.5 1118 101.6 199 18.1
16 Chicago 3729 339.0 2389 217.2 1340 121.8 288 26.2
17 Baltimore 3692 335.6 2604 236.7 1088 98.9 272 24.7
18 Cincinnati 3681 334.6 2488 226.2 1193 108.5 259 23.5
19 Seattle 3582 298.5 2333 194.4 1249 104.1 216 18.0
20 Washington 3546 322.4 2596 236.0 950 86.4 183 16.6
21 Tennessee 3515 319.5 2540 230.9 975 88.6 226 20.5
22 Miami 3480 316.4 2268 206.2 1212 110.2 212 19.3
23 Arizona 3473 315.7 2270 206.4 1203 109.4 213 19.4
24 Minnesota 3464 314.9 1969 179.0 1495 135.9 214 19.5
25 NY Jets 3463 314.8 2359 214.5 1104 100.4 256 23.3
26 Denver 3441 312.8 1684 153.1 1757 159.7 221 20.1
27 San Francisco 3395 308.6 1979 179.9 1416 128.7 262 23.8
28 Kansas City 3346 304.2 2011 182.8 1335 121.4 153 13.9
29 Cleveland 3255 295.9 2190 199.1 1065 96.8 165 15.0
30 St. Louis 3251 295.5 2099 190.8 1152 104.7 140 12.7
31 Indianapolis 3080 280.0 1991 181.0 1089 99.0 150 13.6
32 Jacksonville 2750 250.0 1444 131.3 1306 118.7 138 12.5
Someone Help! ok so in this program i have to read in the file and perform three analytical values from the nfl stats above. i'm to read the data by column only using yards, passing yards and points and store them in an array. i will have to have three functions one to read in the file readfile(); one to calculate the analytical value calculatedata(); and one to report the analytical values back out in a text file report out(); now i have gotten as far as reading in the data and the values i need are stored in the array but my problem now is that when i try to pass the arrays to the calculate data function its not passing the array and for some reason in they yards array its passing 2750 which is the last number in the yards array. Also for one of my analytical values i want to add all the yards in the yards array and then convert it into miles but i have tried to do the calculations in the readfile(); to see if the number comes out right but it doesn't add all the numbers and return me a value instead when i add them it starts from 4951,9907, 14631...and so on until it reaches the final value the only one i wanted!
//functions.cpp
#include <iostream>
#include <fstream>
#include<string>
#include"functions.h"
#include<iomanip>
#define FILE_IN "nflstats.txt"
using namespace std;
float readFile(string teams[], float yards[], float passyards[], float points[])
{
int i = 0;
string trash;
float ftrash1, ftrash2, ftrash3,ftrash4,ftrash5;//trashing other stats that i
//not be using.
double sum =0.,miles =0.,sum2=0.;
ifstream input;
input.open(FILE_IN);
if(!input)
{
cout<<"\n Can't find input file " << FILE_IN;
cout<<"\n Exiting program, bye bye \n ";
exit(1);
}
getline(input,trash);
sum = 0;
while(!input.eof())
{
input>>trash;
input.ignore();
getline(input,teams[i],'\t');//getting team names after tab
input>>yards[i]>>ftrash1>>passyards[i]>>ftrash2>>ftrash3>>ftrash4>>points[i]>>ftrash5;
sum = sum + yards[i];
cout<<sum<<"\n"; // HERE SUM IS COMING OUT TO
//4951
//9897
//14621
//19035
//23421
//27712
//31958
//36135
//40279
//44399
//48510
//52616
//56641
//60441
//64183
//67912
//71604
//75285
//78867
//82413
//85928
//89408
//92881
//96345
//99808
//103249
//106644
//109990
//113245
//116496
//119576
//122326 INSTEAD OF JUST GIVING ME THIS VALUE!!
//cout<<teams[i]<<"\t"<<yards[i]<<"\t"<<ftrash1<<"\t"<<passyards[i]<<"\t"<<ftrash2<<"\t"<<ftrash3<<"\t"<<ftrash4<<"\t"<<points[i]<<"\t"<<ftrash5<<"\n";
}
}
void AnalyzeStats(float yards[], float passyards[], float points[])
{
float sum=0;
for (int i=0; i<31;i++)//evidently this for loop isn't doing anything
{
sum+=yards[i];
}
cout<<sum; // SUM IS COMING OUT TO 2750!
}
void writeOutput()
{
}