import java.util.Scanner;
public class TrueFalseQuiz {
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
String youranswer;
boolean answer = false;
System.out.print("The queens name is Elizabeth? yes or no ");
youranswer = myScanner.toString();
String start = myScanner.next();
{
if (youranswer.equals("yes")) {
answer = true;
}
}
if (answer == true) {
System.out.println("Answer is correct");
} else {
System.out.println("Answer is wrong");
}
}
}
此代码似乎没有将输入与我想要的字符串(“是”或“否”)进行比较。我是初学者,这只是我正在玩的基本代码。