urgent help!! c++ program

This function has to read the input file which has names and numbers.
The input file's first line is:

Thomas Robinson 17 28 10 16 10 11 12 13 8 9 1 1 1 0 1

First & second column: first and last name
3rd-7th column: Points Scored
8th-12th column: Rebounds
13th-17th column: Blocks
Now I have to calculate the average of the points, rebounds, blocks and print it out. Please help. Its due in the morning.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
void generateStats(ifstream& infile, ofstream& outfile)
{
     int lines=0;
     string temp="";
     string name;
     int sum=0;
     string data[16];
     double mock;
     string mock1;
     double ppg, rpg, bpg ;
     double hppg, hrpg, hbpg;
     string fname1, fname2, fname3, lname1, lname2, lname3;
     string tlast1, tlast2, tlast3, tfirst1, tfirst2, tfirst3;
     int k=0;
     int t=0;
     infile.open("basketball.txt");
     outfile<<"\t\t"<<"Basketball Stats Report"<<endl;
     while(!infile.eof())
    {
     lines=lines+1;
     getline(cin, name);
     for(int i=0; i<name.length(); i++)
     {
        if(isspace(name.at(i)))
        {
            data[k]=temp;
            k++;
            temp="";
        }
        else
        {
          temp+=name.at(i);   
        }
     }
     for(int a=0; a<5; a++)
     {
             sum+=data[a+2];
     }
     ppg=sum/5;
     sum=0;
     for(int a=0; a<5; a++)
     {
             sum+=data[a+7];
     }
     rpg=sum/5;
     sum=0;
     for(int a=0; a<5; a++)
     {
             sum+=data[a+12];
     }
     bpg=sum/5;
     mock=(ppg*5)+(rpg*10)+(bpg*25);
     mock1=mock_draft_eligibility(mock);
     outfile<<"--------------------------------------------------------------------"<<endl;
     outfile<<"Player Name: "<<data[0]<<" "<<data[1]<<endl;
     outfile<<"\t"<<"Points per game (Last 5 games): "<<ppg<<endl;
     outfile<<"\t"<<"Rebounds per game (Last 5 games): "<<rpg<<endl; 
     outfile<<"\t"<<"Blocks per game (Last 5 games): "<<bpg<<endl;  
     outfile<<"\t"<<"Mock Draft Points: "<<mock<<endl;
     outfile<<"\t"<<"Draft Eligibility: "<<mock1<<endl;  
     t=t+1;
highest_scorer(ppg, hppg, fname1, tfirst1, lname1, tlast1)

highest_scorer(rpg, hrpg, fname2, tfirst2, lname2, tlast2)

highest_scorer(bpg, hbpr, fname3, tfirst3, lname3, tlast3)
  }
    outfile<<"The player averaging the highest points per game is "<<tfirst1<<” “<<tlast1<<" with "<<hppg<<"ppg."<<endl;
    outfile<<"The player averaging the highest rebounds per game is "<<tfirst2<<” “<<tlast2<<" with "<<hrpg<<"rpg."<<endl;
    outfile<<"The player averaging the highest points per game is "<<tfirst3<<” “<<tlast3<<" with "<<hbpg<<"bpg."<<endl;
}
Topic archived. No new replies allowed.