Java-------Registration, login more than 3 times after the program quits

Source: Internet
Author: User

/** implement registration, and login */public class login {    public static void main (String[] args)  {                 scanner in=new scanner (system.in);         System.out.println ("******** User registration *********");         system.out.println ("Please enter user name:");         string username=in.nextline ();         system.out.println ("Please enter password:");         string password=in.nextline ();                 //keep the user name and password entered         users u =  new users (Username,password);         login login=new  login ();        login.setuser (U);         SYSTEM.OUT.PRINTLN ("Registered successfully! ");                 System.out.println ("******** User login *********");         int icount=0 ;//Login Count         do{             system.out.println ("Please enter user name:");             username=in.nextline ();                         system.out.println ("Please enter password:");             password=in.nextline ();             if (Login.userlogin (Username,password)) {      &nBSP;          SYSTEM.OUT.PRINTLN ("Login Successful");                 break;             }else{                 iCount ++;                  if (icount >= 3 &&  Login.userlogin (Username,password)  == false) {                     system.out.print ("Login failed more than three times, the program is about to exit!") ");                     system.exit (0);                 }else{                     System.out.println ("Please check user name and password");                     }                 }            }while ( True);        }                    //determine if the user name and password are correct     public   boolean userlogin (String username,string password) {                 if (this.user.uesrname.equals (username)  & & this.user.password.equals (password)) {             return true;        }else{             return false;        }         }        Users user;     public void setuser (Users user) {         this.user=user;    }}//User Class class users{         String uesrname;    String password;         //Construction Method     public users (String username,string password) {         this.uesrname=username;         this.password=password;    }    }=================== Implementation Results ======== ================******** User Registration * *Please enter the user name: Zhangsan Please enter the password: 11 Registration Success! User Login ********* Please enter the user name: Zhangsan Please enter the password: 12 Please check the user name and password Please enter the user name: Zhangsan Please enter the password: 11 Login Successful

Java-------Registration, program exits after logging in more than 3 times

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.