Я начал изучать Java в начале этой неделе (понедельник), и теперь в то время как раз проходя от упражнений http://programmingbydoing.com/ (Specific физических упражнений я делаю это http://programmingbydoing.com/a/a-little-quiz.html)Не удается найти символ. Java компилятор ошибка
и теперь я столкнулся с ошибкой что я не могу понять.
import java.util.Scanner;
public class Quiz
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
String ready,answer3;
int answer1,answer2, score;
score = 0;
System.out.println ("Are you ready for a quis?(Y/N) ");
ready = keyboard.next();
if (ready == Y)
{
System.out.println ("Great, let's get to it then!");
}
else if (ready == N)
{
System.out.println ("Well since you did start this program of your own volition I assume you are ready and you're simply having a go at me.");
}
else
{
System.out.println ("Error, wrong input!");
}
System.out.println();
System.out.println ("Q1) What is the capital of Australia?");
System.out.println (" 1) Brisbane");
System.out.println (" 2) Sydney");
System.out.println (" 3) Canberra");
answer1 = keyboard.nextInt();
if (answer1 == 1)
{
System.out.println ("Sorry, Canberra is the capital of Australia");
}
else if (answer1 == 2)
{
System.out.println ("Sorry, Canberra is the capital of Australia");
}
else if (answer1 == 3)
{
System.out.println ("Correct!");
score = score+1;
}
else
{
System.out.println ("Error, wrong input!");
}
System.out.println();
System.out.println ("Q2) Can you store the value 'cat' in a varible of the int type? ");
System.out.println (" 1) Yes");
System.out.println (" 2) No");
answer2 = next.keyboardInt();
System.out.println();
if (answer2 == 1)
{
System.out.println ("Sorry, 'cat' is a string, ints can only store numbers.");
}
else if (answer2 == 2)
{
System.out.println ("That's right!");
score = score+1;
}
else
{
System.out.println("Error, wrong input");
}
System.out.println();
System.out.println ("Did vikings wear horned helmets in combat?(Y/N)");
System.out.println (" 1) Yes");
System.out.println (" 2) No");
answer3= keyboard.next();
System.out.println();
if (answer3 == Y)
{
System.out.print (" That's wrong, the only times a viking would ever have..... nevermind let's proceed with the quiz");
}
else if (answer3 == N)
{
System.out.println ("Correct!");
score = score+1;
}
else
{
System.out.println ("Error, wrong input!");
}
System.out.println ("Overall, you got a total score of " + score + " out of 3 possible.");
System.out.println ("Thanks for playing");
}
}
Я ценю любую помощь, которую любой может предоставить!
Сообщите, пожалуйста, код ошибки. –
Какая ошибка? –