First of all, I am new to this website and coding so please forgive my rookie mistakes, second of all my problem is, I intended to make a quiz via eclipse software using java coding (obviously). But everytime i run it, even when i type in the right answer it reacts like i typed in the wrong answer. Could you please point out my mistake?
import java.util.*;
public class Quiz {
public static void main(String[] args) {
// TODO Auto-generated method stub
@SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
System.out.println("Hi! Welcome to the Quiz! Please insert your username.");
String userName = in.nextLine();
System.out.println("Welcome " + userName + "! Let's start! Your first question is what is the capital of Norway?");
String answer = in.nextLine();
if (answer == ("Oslo"))
System.out.println("Good Job! Your next question is how many states are there in U.S.A.?");
else
{
System.out.println("You've failed!");
}
{
@SuppressWarnings("unused")
String answer1 = in.nextLine();
if (answer1 == ("50"))
System.out.println("Well done! Your next question is where did the first football world cup happen?");
else
{
System.out.println("You've failed!");
}
String answer2 = in.nextLine();
if (answer2 == ("Uruguay"))
System.out.println("Well done! Your next question is");
else
{
System.out.println("You've failed!");
}
}
}
}