Q
Q
Quickneed Svead2019-08-16 02:00:48
Java
Quickneed Svead, 2019-08-16 02:00:48

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

1 answer(s)
M
Maxim Moseychuk, 2019-08-16
@fshp

Apparently spaces around Player

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question