java 初级 问题 急~~~

来源:百度知道 编辑:UC知道 时间:2024/06/14 15:05:48
我的问题是把这数列做成用户名密码的形式,然后再算出来总共出现过多少次没有找到用户名,密码不匹配,还有成功,我做好了前面的匹配,可是不会算,请大侠指教

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