I won't say much nonsense, the key code is as follows:
import java.util.*;public class Demo04 {public static void main(String[] args){//Declare the variable String root="jim";//Username int passwd=123456;//Password int time=0;//Number of loops int sum=0;//Total number of times Scanner input=new Scanner(System.in);//Get keyboard input//For(time=2;time<=3&&time>=0;time--){//User input System.out.print("Please enter username");root=input.next();System.out.print("Please enter password");passwd=input.nextInt();sum++;//Defend whether the user input username is jim and password=123456;if("jim".equals(root)&&passwd==123456){System.out.println("Welcome to log in to MyShopping system");break;}//When the user input times are less than three, else if(sum<3){System.out.println("Input error, you still have "+time+" chance/n"); continue;//When the user enters 3 errors;}else if(sum==3){System.out.println("Input error, you still have "+time+" chance/n");System.out.println("Sorry, you all have errors in 3 times");}}}}}}}The above is the Java user login verification code introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!