1, the program design idea: Cycle six randomly generated six characters combined into a random string, prompting the input to determine whether two strings are equal
2. Program Flowchart
3. Program source code
1 //Letter 1605-1 Liu Sixiang 201635792 ImportJavax.swing.JOptionPane;3 Public classRandomstr4 {5 Public Static voidMain (string[] args)6 {7 //defining an empty string8String result = "";9String message = "";TenString str = ""; One //Cycle 6 times A for(inti = 0; I < 6; i + +) - { - //generates an integer of type 97~122 int the intIntval = (int) (Math.random () * 26 + 97); - //after casting intvalue to char after connecting to result -result = result + (Char) intval; - } + - while(true)//Enter the verification code + { Astr = Joptionpane.showinputdialog (NULL, "Please enter the CAPTCHA:" +result, "enter", joptionpane.information_message); at - if(Str.equals (Result))//determine if the verification code is correct - { -Joptionpane.showmessagedialog (NULL, "Verify Success", "Prompt", joptionpane.information_message); - Break; - } in Else - { toJoptionpane.showmessagedialog (NULL, "Code input error, please re-enter", "Prompt", joptionpane.warning_message); + } - } the } *}
4. Experimental results
Tutorial 01_java Basic Grammar [experimental task four]