Java Landing Interface Experiment Report

Source: Internet
Author: User

1. Design Ideas

First, name name, enter a name and password with a message box, then use the type conversion to generate a six-bit verification string, enter the verification code with the message box, and then determine if the input verification code is correct, if the correct display verification is successful, if the failure shows verification failure re-enter the name password verification code, until the input is correct.

2. Program Flowchart

3. SOURCE program

Package Lab task four;
Import Java.util.Scanner;
Import Javax.swing.JOptionPane;
public class Randomstr
{
public static void Main (string[] args)
{
String name;//defines the login name
String number;//Definition Verification Code
String mima;//defines the password
int q=0;//defines a number that is used to determine whether to jump out of a loop
Do
{
Name=
Joptionpane.showinputdialog ("Please enter login name:");//message box Enter login name
Mima=
Joptionpane.showinputdialog ("Please enter password:");//message box enter password

Define an empty string
String result = "";
Cycle 6 times
for (int i = 0; i < 6; i + +)
{
Generates an integer of type 97~122 int
int intval = (int) (Math.random () * 26 + 97);
After casting intvalue to char after connecting to result
result = result + (char) intval;
}
Number=
Joptionpane.showinputdialog ("Verification Code" +result);//message box output verification code and enter a verification code,
Output random string

if (number.equals (Result))//Determine the input verification code and give the verification code is consistent
{
Joptionpane.showmessagedialog (
NULL, "Validation succeeded", "Results",//output validation successful in message box
Joptionpane.plain_message);
Q=1;

}
if (!number.equals (Result))//Determine the input verification code and the given verification code is consistent
{
Joptionpane.showmessagedialog (
NULL, "Captcha error, re-enter", "Results",//output sum in message box
Joptionpane.plain_message);
}
}while (q!=1);//When the CAPTCHA input is correct, it jumps out of the loop
}

}

4. Results

5. Experimental summary

This program does not appear as required by the overall landing page, I put them in the form of a message box to sign in. In this program I learned that Java randomly generated an integer, but also to edit the message box code more familiar with, Next, I will learn how to display the overall landing page.

Java Landing Interface Experiment Report

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.