When running below program I'm thinking that it should print out "Authentication successful" if I input "john smith" as user name and "12345" as userID, but instead it just comes back with "Authentication failed". I am calling this method in the Main class. Any suggestions?
package com.company;
import java.util.Scanner;
public class Account {
public String userNameInput;
public String userIDInput;
public String userName = "john smith";
public String userID = "12345";
public void userDetails(){
Scanner userInput = new Scanner(System.in);
System.out.println("Please enter user name:");
userNameInput = userInput.next().toLowerCase();
System.out.println("Please enter user ID:");
userIDInput = userInput.next();
if(userNameInput.equals(userName) && userIDInput.equals(userID)){
System.out.println("Authentication successful");
} else{
System.out.println("Authentication failed!!");
}
}
}
Aucun commentaire:
Enregistrer un commentaire