Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Create class GuessTheNumber

Declare global variable NoofGuesses

Define function void play


Initialize noofGuesses to zero
Initialize guess value to some random value
Call the function askForGuess by passing guess value

create userGuess variable


enter value to userGuess
if userGuess>guessValue
print as guess is too high
else if userGuess<guessValue
print as guess is too low

check if userGuess==guessValue
then
print as you guessed correctly in "NoofGuesses" times

To check if the number is between 1 to 10


if (userguess<1 || guess>10)
print as number is out of range

Create class GuessTheNumberTest


Initialize main method
Call method play
Ask user to play again
Use do.. while loop

You might also like