2 qq 40233378 qq_40233378 于 2017.09.14 10:36 提问

知道下标index怎么修改会员和积分
String a = "";
    custNo[0] = 1900;
    custNo[1] = 1711;
    custNo[2] = 1623;
    custNo[3] = 1545;
    custNo[4] = 1464;
    custNo[5] = 1372;
    custNo[6] = 1286;
    custNo[7] = 4444;

    custBirth[0] = "08/05";
    custBirth[1] = "07/13";
    custBirth[2] = "06/26";
    custBirth[3] = "04/08";
    custBirth[4] = "08/16";
    custBirth[5] = "12/23";
    custBirth[6] = "12/21";
    custBirth[7] = "05/06";

    custScore[0] = 2000;
    custScore[1] = 4000;
    custScore[2] = 5000;
    custScore[3] = 2200;
    custScore[4] = 1000;
    custScore[5] = 3000;
    custScore[6] = 10080;
    custScore[7] = 1000;
    System.out.println("我行我素购物管理系统 > 客户信息管理 > 修改客户信息\n");
    System.out.print("请输入会员号:");
    Scanner input = new Scanner(System.in);
    int custno = input.nextInt();
    int index = 0;
    boolean con = false;
    for (int i = 0; i < custNo.length; i++) {//判断会员
        if (custNo[i] == custno) {
            index=i;
            con = true;
        }               
    }
    if (con==false) {
        System.out.println("输入错误");
        System.out.println("请'n'返回上一级菜单:");
        String is = input.next();
        if ("n".equals(is)) {
            showManagement();
        } else {
            while (!"n".equals(is)) {
                System.out.print("输入错误, 请重新'n'返回上一级菜单:");
                is = input.next();
            }
            showManagement();
        }
    }
    System.out.println(" 会员号            生日             积分");
    System.out.println("------------|------------|---------------");
    System.out.println(custNo[index] + "\t" + custBirth[index] + "\t"
            + custScore[index]);
    do{
    System.out.println("**************************************************************");
    System.out.println("           1.修 改 会 员 生 日.");
    System.out.println("           2.修 改 会 员 积 分.");
    System.out.println("**************************************************************");
    System.out.print("请选择,请输入数字:");
    int choos = input.nextInt();
    System.out.println("");
    switch(choos){
    case 1:
        System.out.print("请输入修改后的生日:");
        String custbirth = input.next();
        custBirth[index] = custbirth;
        System.out.println("修改成功");
        break;
    case 2:
        System.out.print("请输入修改后的积分:");
        int custscore = input.nextInt();
        custScore[index] = custscore;
        System.out.println("修改成功");
        break;
    }           
    }while("y".equals(a));
        System.out.print("是否修改其他属性(y/n):");
         a = input.next();
         System.out.println("请'n'返回上一级菜单:");
            String is = input.next();
            if ("n".equals(is)) {
                showManagement();
            } else {
                while (!"n".equals(is)) {
                    System.out.print("输入错误, 请重新'n'返回上一级菜单:");
                    is = input.next();
                }
                managemenu();
            }
}

1个回答

heliangb46
heliangb46   2017.09.14 13:12
    case 2:
        System.out.print("请输入修改后的积分:");
        int custscore = input.nextInt();
        custScore[index] = custscore;
        System.out.println("修改成功");
        break;
    }
heliangb46
heliangb46 回复qq_40233378: 对啊,没问题啊,你现在运行不好使?
2 个月之前 回复
qq_40233378
qq_40233378 没什么问题啊
2 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片