自己写的一个小的登陆程序
import java.util.Scanner;
public class zy3 {
public static void main(String[] args) {
String[] user = { "my", "you" };
int[] password = { 1, 2 };
if (lingo(user, password)) {
System.out.println("登录成功");
} else {
System.out.println("你输入的账号名或密码不正确");
}
}
public static boolean lingo(String[] user, int[] password) {
Scanner sc = new Scanner(System.in);
System.out.println("输入用户名");
String userName = sc.nextLine();
Scanner cs = new Scanner(System.in);
System.out.println("输入密码");
int passwords = cs.nextInt();
int m = 0;
for (int i = 0; i < user.length; i++) {
if (user[i].equals(userName)) {
m = i;
}
}
if (password[m] == passwords) {
return true;
}
return false;
}
}
import java.util.Scanner;
public class zy3 {
public static void main(String[] args) {
String[] user = { "my", "you" };
int[] password = { 1, 2 };
if (lingo(user, password)) {
System.out.println("登录成功");
} else {
System.out.println("你输入的账号名或密码不正确");
}
}
public static boolean lingo(String[] user, int[] password) {
Scanner sc = new Scanner(System.in);
System.out.println("输入用户名");
String userName = sc.nextLine();
Scanner cs = new Scanner(System.in);
System.out.println("输入密码");
int passwords = cs.nextInt();
int m = 0;
for (int i = 0; i < user.length; i++) {
if (user[i].equals(userName)) {
m = i;
}
}
if (password[m] == passwords) {
return true;
}
return false;
}
}