0

gameIssue: someone could tell me why this game isn't working like it should?

public class Game { public static void main(String[] args) { Scanner input = new Scanner(System.in); String secretWord = "bagel"; String attempt = ""; int numAttemtps = 0; int limAttemtps = 3; while (numAttemtps < limAttemtps && attempt != secretWord) { System.out.print("guess the secret word: "); attempt = input.nextLine(); ++numAttemtps; } if (attempt == secretWord){ System.out.println("you won!!!"); } else if (numAttemtps == limAttemtps){ System.out.println("you lost!!"); } } }

2nd May 2020, 1:48 AM
Claudio Catalán Sandoval
Claudio Catalán Sandoval - avatar
1 ответ
+ 1
What type of bug are you getting?
2nd May 2020, 8:27 AM
Souptik Nath
Souptik Nath - avatar