Just learn Java white want to ask a question about reading the keyboard input numbers

Source: Internet
Author: User

Import java.util.*;

public class Main {

public static void Main (string[] args) {

Main main= new Main ();

Menu start = new menu ();

Main.checkid ();

System.out.println ("Welcome". ");

Scanner sc = new Scanner (system.in);

int select = Sc.nextint ();

Switch (SELECT) {

Case 1:;

}

}

Check Login

private void Checkid () {

Used to read input

Scanner input = new Scanner (system.in);

Boolean loginStatus = false;

Number of password errors recorded

int count = 0;

while (LoginStatus = = False) {

if (Count >= 3) {

SYSTEM.OUT.PRINTLN ("error more than three times, account freezes");

System.exit (-1);

}

System.out.println ("Please enter your account:");

String name = Input.next ();

System.out.println ("Please enter password:");

String password = input.next ();

if ("admin". Equals (name) && "admin". Equals (password)) {

LoginStatus = true;

Remember to close the scanner.

Input.close ();

SYSTEM.OUT.PRINTLN ("Login Successful");

Break

} else {

System.out.println ("Incorrect account or password, please re-enter");

count++;

}

}

}

Exception in thread "main" java.util.NoSuchElementException

At Java.util.Scanner.throwFor (scanner.java:907)

At Java.util.Scanner.next (scanner.java:1530)

At Java.util.Scanner.nextInt (scanner.java:2160)

At Java.util.Scanner.nextInt (scanner.java:2119) more 0

? Welcome to join 618237474, find a group of private chat, send a huge amount of study materials free to send

Just learn Java white want to ask a question about reading the keyboard input numbers

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.