Verify the validity of the login information and the validity of the login

Source: Internet
Author: User

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. ");}}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.