Bowling Program

I need help with this bowling program. I am suppose to use nested for loops to determine the averages of bowlers, their respective teams, and find out which team wins. All data must be sent to an external file. Here is what I have so far:

/*****************************************************************************
file Template_Project_5.cpp

Your description to the reader goes here!
*******************************************************************************/


#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdlib>

using namespace std;

int main()
{

int score,sum,bowler1_avg,bowler2_avg,bowler3_avg,
bowler4_avg, bowler5_avg,team1_avg,team2_avg,team3_avg,
win_avg; //this is the winning average for the tournament
ofstream outs;

//Describe program to user goes here


outs.open("bowl.txt",ios::app);

//Open external file and allow for appending to the file. Add your code.


//The following is pseudo-code that should help you set up the actual code
for(int team=1;team<=3;team++)
{
outs<<team;
//Send team number to the external file

//Initialize player averages for the team
bowler1_avg=0;
bowler2_avg=0;
bowler3_avg=0;
bowler4_avg=0;
bowler5_avg=0;

for(int bowler=1;bowler<=5;bowler++)
{
sum=0;
//Initialize sum of scores for each bowler to zero


for(int score=1;score<=5;score++)
{
cout<<" \n Enter score for bowler " <<score+1<<" ";
cin>>score;
score+=sum;
}


//Enter the score for the bowler from the keyboard and add it to
//the sum of scores for this bowler so far.

}//end for each game

switch(sum)
{
case 1:bowler1_avg;
cout<<bowler1_avg;
break;
case 2:bowler2_avg;
cout<<bowler2_avg;
break;
case 3:bowler3_avg;
cout<<bowler3_avg;
break;
case 4:bowler4_avg;
cout<<bowler4_avg;
break;
case 5:bowler5_avg;
cout<<bowler5_avg;
break;



//Use a switch statement to select the particular bowler, compute the
//the average score for this bowler, and send it to the external file.


}//end for each bowler

team1_avg==bowler1_avg+bowler2_avg+bowler3_avg+bowler4_avg+bowler5_avg/5;
team2_avg==bowler1_avg+bowler2_avg+bowler3_avg+bowler4_avg+bowler5_avg/5;
team3_avg==bowler1_avg+bowler2_avg+bowler3_avg+bowler4_avg+bowler5_avg/5;

outs<<team1_avg,team2_avg,team3_avg;
//Compute team average for each team and send team average
//to external file. Use a switch statement to select the
//particular team for whcih the team average is being computed.
//Make sure each team average is properly rounded to an integer value.



}//End for each team
if(team1_avg>team2_avg&&team3_avg)
{
team1_avg=win_avg;
cout<<"Team 1 is the winner! They bowled"<<win_avg<<"as a team!\n";
}
else if(team2_avg>team1_avg&&team3_avg)
{
team2_avg=win_avg;
cout<<"Team 2 is the winner! They bowled"<<win_avg<<"as a team!\n";
}
else if(team3_avg>team1_avg&&team2_avg)
{
team3_avg=win_avg;
cout<<"Team 3 is the winner! They bowled"<<win_avg<<"as a team!\n";
}


//From the team average computed above, determine which team wins or
//which tams tie in the tournament. You'll need to apply nested if else
//logic to do this. Send the result to the external file.

outs<<endl<<endl<<endl;
outs.close();
system("PAUSE");
return 0;
}



I don't understand what needs to be placed inside the for loops to make them compute. There are 5 bowlers on a team, 3 teams total.
Topic archived. No new replies allowed.