right now, my accummilator continuously adds all of the scores together for all players. what can i do to fix this? i hope this makes sense.

10-31-2010, 04:45 AM

Fubarable

You need to have the player's total be intialized to zero before you add the player's score. So do that in the outer for loop before the individual player's for loop.

Also, you'll need to calculate the player's average after the inner (player's) for loop has been completed because only then will the individual scores have been all added up.

Oh, please fix your indentation formatting since it is atrocious and makes your code quite difficult to read. If you're a student, bad formatting will likely get marks taken off of your grade.

10-31-2010, 08:58 AM

Eranga

On this you've pointed above post.

Code:

for (int i =0; i< numberOfGames; i++) { // 0, 1, 2 (3 games for each bowler)
System.out.print("Please enter your score: ");//prompt for score
score = input.nextInt(); //read in score
playerTotal = score;//accumulate to get total_score
playerAvg += playerTotal/numberOfGames;//divide total_score by 3 to get average score for each player
}

Calculate the average from outside the loop, and calculate the total inside that.