java 初级 问题 急~~~
来源:百度知道 编辑:UC知道 时间:2024/09/21 13:56:47
import java.util.Scanner;
public class Menu
{
private void menu()
{
System.out.println("*** Welcome to the menu system ***");
System.out.println("Press \"1\" to XXX");
System.out.println("Press \"2\" to YYY");
System.out.println("Press \"3\" to ZZZ");
System.out.println("Press \"4\" to quit!");
}
public void demo()
{
Scanner in = new Scanner(System.in);
while (true)
{
menu();
if (in.hasNextInt())
{
int option = in.nextInt();
switch (option)
{
case 1:
int StudentNo, n, p
while (true) {
System.out.println("Please enter your student number");
StudentNo = in.nextInt();
for (n = 0; n < 13; n++) {
if (studentNo[n] == StudentNo) {
for (p = 0; p < 3; p++) {
System.out.println("Please enter your password.");
Password = in.next();
if (password[n].equals(Password)) {
System.out.println("User accepted!");
counter2++;
break;
} else {
System.out.println("Wrong Password!!!Try again!");
counter1++;
continue;
}
}
break;
}
这个地方逻辑有问题...
你先画一下流程图.
感觉你的思路太乱了..
while (true) {
System.out.println("Please enter your student number");
StudentNo = in.nextInt();
for (n = 0; n < 13; n++) {
if (studentNo[n] == StudentNo) {
for