Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a guessing game (pseudocode) that generates a random number and let a pla

ID: 3537218 • Letter: D

Question

Design a guessing game (pseudocode) that generates a random number and let a player try to guess
it. After each guess, you displayed a message indicating whether the player%u2019s
guess was correct, too high, or too low. When the player eventually guessed the
correct number, you displayed a score that represented a count of the number of
guesses that were required. Allow the player to replay the game as many times
as he likes, up to 20 times. When the player is done, display the scores from
highest to lowest, and display the mean and median scores.

Explanation / Answer

declare array a[20];

for i=1 to 20

scanf(%d,&g);//Enter Your Guess

a[i]=g;

if(g>tooHighThreshpuld)

display tooHigh

else

display tooLow

print "Your guess is "g;

count=count+1;

end for loop

for i=1 to 19

for j=1 to 20-i-1

if(a[i]<a[j])

swap a[i],a[j]

end if

end for

end for

for i=1 to 20

sum+=a[i];

end for

mean=sum/20;

display mean

median=a[10];

display median

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote