@Lyrae
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
} 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!"); }
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?
@readergirl12
Are you trying to print something?
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.
Okay maybe you dont have enough ink
No, not like printing it literally, it's a java program, so I am trying to run it.
Did you check how many pages are printing?
A window should open when you are about to print a page
I'm trying to run the program, (the game) not print it to a terminal window or literally print it at all.
Okay Try resetting you computer
are you familiar with loops?
No not really
Ok nvm then, thanks for your help anyways ;)
No problem
gh
Join our real-time social learning platform and learn together with your friends!