Phloof_boll
Phloof_boll
JCHJava Community | Help. Code. Learn.
Created by Phloof_boll on 12/9/2024 in #java-help
why does a space " " seem to break a if(scanner.next().equals(answers[i])){
how do i make it not break with a two word answer i tested putting in numbers single words and even connecting words using a "-" instead of a space and they all work but as soon as a space goes into the answers[0] = " " it wont continue
4 replies
JCHJava Community | Help. Code. Learn.
Created by Phloof_boll on 12/8/2024 in #java-help
Am I using the wrong loop or the loop wrong
I'm using java 17 and here's my loop the 'for' is there to print out the 'i' question then i want the 'while' loop to let you type out guesses until you get the correct answer and once you are correct it adds '1' to 'i' so that it prints out the next question as of now what i have before this code is just the q & a string and the scanner and when I run it it prints the first question and every input after does nothing correct answer or not for (int i = 0; i < questions.length;) { System.out.println(questions[i]); while (true) { if (scanner.equals(answers[i])) System.out.println("You are correct"); i =+ 1; }
24 replies