Package Com.hanqi.lianxi;
Import Java.util.Random;
Import Java.util.Scanner;
public class Yanzhengma
{
public static void Main (string[] args)
{
String str = "0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ";
char[] array = new CHAR[4];
Random Suiji = new Random ();
System.out.print ("Verification Code:");
for (int i =0; i<4; i++)
{
Array[i]=str.charat (Suiji.nextint (61));
}
SYSTEM.OUT.PRINTLN (array);
Scanner sr = new Scanner (system.in);
System.out.println ("Please enter the Verification Code:");
String Aaa=new string (array);//convert array type to string type
for (int j=0;j<5;j++)
{
if (Sr.nextline (). Equals (AAA))
{
SYSTEM.OUT.PRINTLN ("input correct");
Break
}
Else
{
if (j<=3)
{
SYSTEM.OUT.PRINTLN ("Input error, please re-enter");
System.out.print ("Verification Code:");
for (int i =0; i<4; i++)
{
Array[i]=str.charat (Suiji.nextint (61));
}
SYSTEM.OUT.PRINTLN (array);
Aaa=new String (array);
}
Else
{System.out.println ("input error, sorry, you have not entered the opportunity");}
}
}
}
}
Randomly generate 4-bit verification code, enter the verification code compared with the generated, enter up to 5 times