for (int i = 0; i < name.length; i++) {
if (name[i].equals(null)) {
System.out.print("用户名:");
name[i]=input.next();
break;
}else{
continue;
} }

解决方案 »

  1.   

    还有equals事匹配字符串的内容,不能equals(null)的 可以这样写equals(“”)
      

  2.   

    这个应该很容易实现啊,主要逻辑很简单,只要弄懂怎么输入输出,if语句,while循环,random,这么简单的还是自己多试试吧。也不用写很多
      

  3.   

    肯定逻辑有问题,不如贴下代码,如果是我的话,我就用一个类来存储用户名、密码、和卡号信息
    然后将注册信息用MAP存储,用户名作为KEY,值就是这个类
      

  4.   


    //不能让你的程序结束了。不然变量就重新初始化。之前数组中的值就没有了。
    while(true){}
      

  5.   

    package loop;import java.util.Scanner;public class LargeSize {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int card =0;
    int []number = new int[5];
    String judge ="";
    int name2 = 0;
    int name1 =0;
    int password1= 0;
    String[] name = new String [1000];
    int[] password = new int [1000];
    int choice =0;
    do {
    System.out.println("*****欢迎登陆奖客富翁系统*****");
    System.out.println("\t\t1.注册");
    System.out.println("\t\t2.登陆");
    System.out.println("\t\t3.抽奖");
    System.out.println("****************************");
    System.out.print("请选择菜单:");
    choice = input.nextInt();
    switch (choice) {
    case 1:
    System.out.println("[奖客富翁系统>注册]");
    System.out.println("请填写个人信息:");
    for (int i = 0; i < name.length; i++) {
    name1 = i;
    if (name[i].equals(null)) {
    System.out.print("用户名:");
    name[i]=input.next();
    break;
    }

    }
    for (int j = 0; j < password.length; j++) {
    password1 = j;
    if(password[j]==0){
    System.out.print("密码:");
    password[j] = input.nextInt();
    break;
    }
    }
    System.out.println("\n注册成功,请您记住您的会员号");
    System.out.println("用户名\t\t密码\t\t会员号");
    System.out.println(name[name1]+"\t\t"+password[password1]+"\t\t"+((int)(Math.random()*9000+1000)));
    break;
    case 2:
    System.out.print("请输入用户名:");
    name[name1+1] = input.next();
    for (int i = name1+1; i < name.length; i++) {

    if (name[i].equals(name[name1])) {
    name2 = i;
    break;
    }else{
    System.out.print("用户名错误,请重新输入:");
    name[i+1] =input.next();
    }
    }
    System.out.print("请输入密码:");
    password[password1+1] = input.nextInt();
    for (int i = password1+1; i < password.length; i++) {

    if (password[i]==password[password1]) {
    break;
    }else{
    System.out.print("用户密码错误,请重新输入:");
    password[i+1] =input.nextInt(); 
    }
    }
    System.out.println("欢迎您:"+name2);
    break;
    case 3:
    System.out.print("[奖客富翁系统>抽奖]");
    System.out.print("请输入您的卡号");
    card = input.nextInt();
    System.out.print("本日的幸运数字为:");
    for (int i = 0; i < number.length; i++) {
    number[i] = (int)(Math.random()*9000+1000);
    System.out.print("\t"+number[i]);
    }
    for (int i = 0; i < number.length; i++) {

    if (number[i]==card) {

    System.out.println("\n恭喜您成为本日的幸运会员");
    break;
    }
    if (i==number.length-1) {
    System.out.println("\n很抱歉!您不是本日的幸运会员");
    }
    }
    break;
    default:
    break;
    }
    System.out.println("继续吗?(y/n)");
    judge = input.next();
    } while (judge.equalsIgnoreCase("y"));
    System.out.println("系统退出谢谢使用");
    }
    }
      

  6.   

    for (int i = 0; i < name.length; i++) {
    name1 = i;
    if (name[i].equals(null)) {
    System.out.print("用户名:");
    name[i]=input.next();
    break;
    }
    为什么不对
      

  7.   

    1:
     if (name[i].equals(null))
    改为
     if (name[i]==null)
    ---------------------
    2:
    case 2 部分:查找用户名要从name[]的0位开始,
      for (int i = name1+1; i < name.length; i++) 
    改为
      for (int i =0; i < name.length; i++) 
    -----------------
      

  8.   

    这个判断也不对,同理,密码的判断也得改
    if (name[i].equals(name[name1])) {
                                name2 = i;
                                break;
                            }else{
                                System.out.print("用户名错误,请重新输入:");
                                name[i+1] =input.next();
                            }
    //改为
    if (name[i].equals(name[name1])) {
        name2 = i;
        break;
    }
    if (i == name.length - 1) {
        System.out.print("用户名错误,请重新输入:");
        name[i + 1] = input.next();
    }
      

  9.   

    来个简单的,抽奖的暂不实现了import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.HashMap;
    public class Client {

    public static void main(String[] args) throws Exception {
    launch();
    }

    public static void launch() throws Exception {
    boolean exit = false;
    Map<String,User> reg = new HashMap<String,User>();

    while(!exit) {
    System.out.println("****欢迎进入奖客富翁系统*****");
    System.out.println("        1.注册");
    System.out.println("        2.登陆");
    System.out.println("        3.抽奖");
    System.out.println("****************************");
    System.out.print("请选择菜单:");

    BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
    String option = read.readLine();
    option = option.replaceAll(" |\t", "");
    System.out.println();

    if("1".equals(option) || "2".equals(option) || "3".equals(option)) {
    if("1".equals(option)) {
    register(reg);
    } else if("2".equals(option)) {
    login(reg);
    } else {
    lottery();
    }
    }

    System.out.print("继续吗?(y/n):");
    read = new BufferedReader(new InputStreamReader(System.in));
    option = read.readLine();
    option = option.replaceAll(" |\t", "");
    if("y".equals(option)) {
    System.out.println();
    System.out.println();
    } else {
    System.out.println("系统推出,谢谢使用!");
    exit = true;
    }
    }
    }

    private static void register(Map<String,User> reg) throws Exception {
    String username = "";
    String password = "";
    String cardno = "";

    System.out.println("[奖客富翁系统 > 注册]");
    System.out.println("请填写个人注册信息");
    System.out.print("用户名:");
    BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
    username = strin.readLine();
    username = username.replaceAll(" |\t", "");
    System.out.print("密     码:");
    strin = new BufferedReader(new InputStreamReader(System.in));
    password = strin.readLine();
    password = password.replaceAll(" |\t", "");
    cardno = String.valueOf(Math.round(1000 + Math.random() * 8999));

    System.out.println("注册成功,请记好您的会员卡号");
    System.out.format("%-6s\t%-10s"+"会员卡号","用户名","密码");
    System.out.println();
    System.out.format("%-6s\t%-10s"+cardno,username,password);
    System.out.println();
    User user = new User();
    user.setUsername(username);
    user.setPassword(password);
    user.setCardno(cardno);
    reg.put(username, user);
    }

    private static void login(Map<String,User> reg) throws Exception {
    String username = "";
    String password = "";

    System.out.println("[奖客富翁系统 > 登录]");
    System.out.print("请输入用户名:");
    BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
    username = strin.readLine();
    username = username.replaceAll(" |\t", "");
    System.out.print("请输入密    码:");
    strin = new BufferedReader(new InputStreamReader(System.in));
    password = strin.readLine();
    password = password.replaceAll(" |\t", "");

    User user = reg.get(username);
    if(user == null) {
    System.out.println("您输入的用户名还没注册!");
    return;
    } else {
    if(!password.equals(user.getPassword())) {
    System.out.println("您输入的密码有误!");
    return;
    } else {
    System.out.println("欢迎您," + username);
    }
    }
    }

    private static void lottery() {

    }
    }
      

  10.   

    重发下吧,格式
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.HashMap;
    public class Client {

    public static void main(String[] args) throws Exception {
    launch();
    }

    public static void launch() throws Exception {
    boolean exit = false;
    Map<String,User> reg = new HashMap<String,User>();

    while(!exit) {
    System.out.println("****欢迎进入奖客富翁系统*****");
    System.out.println("        1.注册");
    System.out.println("        2.登陆");
    System.out.println("        3.抽奖");
    System.out.println("****************************");
    System.out.print("请选择菜单:");

    BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
    String option = read.readLine();
    option = option.replaceAll(" |\t", "");
    System.out.println();

    if("1".equals(option) || "2".equals(option) || "3".equals(option)) {
    if("1".equals(option)) {
    register(reg);
    } else if("2".equals(option)) {
    login(reg);
    } else {
    lottery();
    }
    }

    System.out.print("继续吗?(y/n):");
    read = new BufferedReader(new InputStreamReader(System.in));
    option = read.readLine();
    option = option.replaceAll(" |\t", "");
    if("y".equals(option)) {
    System.out.println();
    System.out.println();
    } else {
    System.out.println("系统推出,谢谢使用!");
    exit = true;
    }
    }
    }

    private static void register(Map<String,User> reg) throws Exception {
    String username = "";
    String password = "";
    String cardno = "";

    System.out.println("[奖客富翁系统 > 注册]");
    System.out.println("请填写个人注册信息");
    System.out.print("用户名:");
    BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
    username = strin.readLine();
    username = username.replaceAll(" |\t", "");
    System.out.print("密     码:");
    strin = new BufferedReader(new InputStreamReader(System.in));
    password = strin.readLine();
    password = password.replaceAll(" |\t", "");
    cardno = String.valueOf(Math.round(1000 + Math.random() * 8999));

    System.out.println("注册成功,请记好您的会员卡号");
    System.out.format("%-6s\t%-10s"+"会员卡号","用户名","密码");
    System.out.println();
    System.out.format("%-6s\t%-10s"+cardno,username,password);
    System.out.println();
    User user = new User();
    user.setUsername(username);
    user.setPassword(password);
    user.setCardno(cardno);
    reg.put(username, user);
    }

    private static void login(Map<String,User> reg) throws Exception {
    String username = "";
    String password = "";

    System.out.println("[奖客富翁系统 > 登录]");
    System.out.print("请输入用户名:");
    BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
    username = strin.readLine();
    username = username.replaceAll(" |\t", "");
    System.out.print("请输入密    码:");
    strin = new BufferedReader(new InputStreamReader(System.in));
    password = strin.readLine();
    password = password.replaceAll(" |\t", "");

    User user = reg.get(username);
    if(user == null) {
    System.out.println("您输入的用户名还没注册!");
    return;
    } else {
    if(!password.equals(user.getPassword())) {
    System.out.println("您输入的密码有误!");
    return;
    } else {
    System.out.println("欢迎您," + username);
    }
    }
    }

    private static void lottery() {

    }
    }