Sunday, July 26, 2009

Somebody help me with "find average by looping"--pseudo code (or c++)?

I can't find out how to manage this problem





captain need to average 3 scores for each player and session





write a program that asks the captain how many player this session.


Use for loop or while loop as means of repeating the programming instrictions to average the player score


for each player and print averages as they are computed.





help me please.. thank you so much

Somebody help me with "find average by looping"--pseudo code (or c++)?
Ok, here is a rough idea that would need error checkin and output formatting.





#include %26lt;iostream.h%26gt;


main()


{


int nPlayers;


cout%26lt;%26lt;"enter no. of players";


cin %26gt;%26gt; nPlayers;


for(int i = 0; i %26lt; nPlayers; i++)


{


double avgScore = 0.0;


for(int j = 0; j %26lt; 3; j++)// hard coded sessions!


{


double score;


cout%26lt;%26lt;"enter session score";


cin %26gt;%26gt; score;


avgScore += score;


}// end for j...


avgScore /=3;





cout%26lt;%26lt;"average: " %26lt;%26lt; avgScore %26lt;%26lt; "\n";


}// end for i...


}


No comments:

Post a Comment