Verify the validity of the login information and the validity of the login
Most system login modules receive the login information entered by the user through the keyboard, which will be verified by the login module. If you use the specified user name and password, allow the program to log on, otherwise, the user is rejected. This example uses if... The else statement performs multi-condition judgment to verify the login information.
Create a CheckLogin class in the project. In the main method of this class, receive the login user name and login password entered by the user, then use the if Condition Statement to determine the user name and password respectively, and output the login verification result. The Code is as follows:
Import java. util. required; public class CheckLogin {public static void main (String [] args) {// method stub automatically generated by TODO @ SuppressWarnings ("resource") implements scan = new feature (System. in); // create a scanner System. out. println ("Enter the logon User Name"); String username = scan. nextLine (); System. out. println ("Enter the logon password:"); String password = scan. nextLine (); if (! Username. equals ("u539f") {System. out. println ("the user name is invalid. ");} Else if (! Password. equals ("u539fpassword") {System. out. println ("the logon password is incorrect. ");} Else {System. out. println (" congratulations, the logon information has been verified. ");}}}