Ask your own question, for FREE!
Computer Science 23 Online
OpenStudy (anonymous):

@Lyrae

OpenStudy (anonymous):

boolean correctGuess = false; for(int i = 0; i < 10 && !correctGuess; i++) { System.out.println("Enter a number in the range of: " + minNumber + " to " + maxNumber + "You have up to 10 guesses."); int userValue = In.getInt(); if (userValue == randomNumber) correctGuess = true; if (userValue > randomNumber && userValue <= maxNumber) { System.out.println("Your guess is too high."); } else if (userValue < randomNumber && userValue >= minNumber) { System.out.println("Your guess is too low."); } else if (userValue >maxNumber || userValue < min

OpenStudy (anonymous):

} else if (userValue >maxNumber || userValue < minNumber) { System.out.println("Invalid guess, guess a number within the specified range."); } else if (correctGuess) { System.out.println("Congratulations! You guessed the number correctly!You have won the game!"); } else if (userValue < randomNumber && userValue >= minNumber && correctGuess == true) { System.out.println("Sorry, you ran out of guesses. The computer wins!"); }

OpenStudy (anonymous):

It does not print the sorry part after 10 guesses have been used up and the number was not guessed, but it prints it when the correct guess has been given. Any suggestions?

OpenStudy (anonymous):

@readergirl12

OpenStudy (readergirl12):

Are you trying to print something?

OpenStudy (anonymous):

Yes, so when the 10 guesses have been used up, I want the program to print "Too low" AND "sorry, you lost..etc" but right now it's just printing the too low part. And it's printing the sorry you lost part when someone guesses correctly before the end of the 10 attempts.

OpenStudy (readergirl12):

Okay maybe you dont have enough ink

OpenStudy (anonymous):

No, not like printing it literally, it's a java program, so I am trying to run it.

OpenStudy (readergirl12):

Did you check how many pages are printing?

OpenStudy (readergirl12):

A window should open when you are about to print a page

OpenStudy (anonymous):

I'm trying to run the program, (the game) not print it to a terminal window or literally print it at all.

OpenStudy (readergirl12):

Okay Try resetting you computer

OpenStudy (anonymous):

are you familiar with loops?

OpenStudy (readergirl12):

No not really

OpenStudy (anonymous):

Ok nvm then, thanks for your help anyways ;)

OpenStudy (readergirl12):

No problem

OpenStudy (anonymous):

gh

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!