Tutorial 01_java Basic Grammar [experimental task four]

Source: Internet
Author: User

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]

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.