import java.util.Scanner;
public class Questionaire {
public static void main(String[] args) {
String name;
String ansOne;
Scanner input = new Scanner(System.in);
System.out.print("Hello, welcome to the super awesome quiz. Let's get things going. What is your name?");
name = input.nextLine();
System.out.print("Okay, hi " + name + " I'm just going to call you Bob.");
System.out.print(" Question 1: What is the name of your dog?");
ansOne = input.nextLine();
if (ansOne == "Avagantamos") {
System.out.print("Correct!");
} else {
System.out.print("Wrong! The correct answer was Avagantamos!");
}
}
}
所以基本上,當它要求你輸入你的狗的名字時,即使你輸入Avagantamos也是不正確的。我仍然非常喜歡,這真是令人沮喪,所以非常感謝任何迴應的人。跳過如果語句
歡迎來到SO。 +1提供所有必要的細節以供某人回答您的問題(您會驚訝多久不是這種情況)。輸入代碼時,請嘗試正確格式化,並縮進整個塊4個空格,以便SO將使用固定寬度的字體顯示它。在輸入頁面上有一個按鈕「{}」,它將縮進所選的4個空格。安德魯爲你做了這件事。 – 2012-03-27 01:10:48