Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>but i need the program to ask the player if they want to play again after the game is done and act accordingly
Try creating a simple program; one that concentrates purely on getting the program to loop back to the beginning when the user chooses the option to play again.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
put the whole thing you want to repeat in a do- while loop...
ask each time before the loop ends if the user wants to play again...
and keep a count of no. of times the loop runs...that would be no. of games played...
sum up noOf guesses..like
int sum=0;//outside the loop
sum+=noOfguesses;//inside the loop
avgNoOfGuesses=sum/noofgamesplayed;//outside the loop after it terminates
tracethepath
Junior Poster in Training
54 posts since Jul 2007
Reputation Points: 8
Solved Threads: 4