Answer the question
In order to leave comments, you need to log in
Java wrong sequence?
It is necessary that after you enter the Player, the if statement is executed, what is wrong?
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner databaseLogin = new Scanner(System.in);
Scanner databasePassword = new Scanner(System.in);
String name1 = "Login: ";
String name2 = "Player ";
String error = "error ";
String name3 = "Password: ";
////////////////////////////////////////////////////////////////
System.out.print("" + name1 );
System.out.println( "" + name1 + "" + databaseLogin.nextLine() );
if (databaseLogin.equals(" Player ")) {
System.out.print("" + name3 );
System.out.print(" Enter password: " + databasePassword.nextLine() );
} else {
System.out.println("" +error );
}
//////////////////////////////////////////////////////
if (databasePassword.equals(" 123qwe456 ")) {
System.out.println(" Welcome to the kingdom! ");
} else {
System.out.println("" + error );
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question