Here is the problem

A local baseball team wants to automate their data entry and statistics.

Input: zero or more lines input from the keyboard (or a file if you want to do it that way) where each line will have four integers on it. (Assume that this will be true.) The first integer will be a player number 1 through 8 (do not ever step out of the array bounds! I don't care how many players you have.) followed by a number of hits, a number of walks and a number of outs in that order. There may be more than one entry for any given player. Not all players are guaranteed to have entries. Data entry terminates when a negative player number is read.

Output: Produce a table showing each player's cumulative scores and their batting average which will be defined as:

(float) total_hits/(total_hits + total_outs) Remember that the sum will be an integer. At the end, write the team average (do not include the players who did not bat in the average) and (optional/extra credit) find the player with the highest average.

Errors: Input will conform to the above; however, there may be invalid player(s) entered. In that event, just skip that player's whole record and go on. Generate an error message showing all of the invalid data.

A player who never comes to bat will have division by zero in the average. Let's arbitrarily call this a -1.0 because we have to call it something.

Store your data internally as 0..7 but number the output as 1..8. Note that the input is also in terms of 1..8

Example of output showing 8 players"

Player Hits Walks Outs Average

1 19 16 20 0.487

2 16 17 23 0.410

3 15 12 17 0.469

4 13 14 4 0.765

5 16 17 12 0.571

6 18 15 6 0.750

7 22 6 22 0.500

8 0 0 0 -1

Team average: 0.555

Higest player is #6 with: 0.765 (optional/extra credit)

Here is my programming:

#include <iostream>

#include <iomanip>

using namespace std;

void getdata(int&, int&,int&,int&);

//global

const int MAX=2;

int main()

{

int p_num[MAX],total_hits[MAX],total_outs[MAX],total_walks[MAX];

int indexp;

float average=0;

for(int i=0; i<MAX; i++)

p_num[i]=0;

for(int i=0; i<MAX; i++)

total_hits[i]=0;

for(int i=0; i<MAX; i++)

total_outs[i]=0;

for(int i=0; i<MAX; i++)

total_walks[i]=0;

//while()

for(int i=0; i<MAX; i++)

{

cout<<"enter player number Then enter hits, followed by outs and walks\n";

cin>>p_num[i]>>total_hits[i]>>total_outs[i]>>total_walks[i];

}

cout<<"Player"<<setw(5)<<"Hits"<<setw(5)<<"Outs"<<setw(5)<<" walks"<<setw(5)<<"\n";

for(int i=0; i<MAX; i++)

cout<<setw(5)<<p_num[i]<<setw(5)<<total_hits[i]<<setw(5)<<total_outs[i]<<setw(5)<<total_walks[i]<<endl;

cin.get();

cin.ignore();

return 0;

}

I know i need a while loop to tell if the number is negative while(p_num>0)

but i keep getting an error when i include my while loop please help me

Thank you