实现自动计算会员折扣:已知会员号,根据会员号查找目前的积分,然后计算该会员所享受的会员折扣。
        //使用数组存储商品信息
//使用数组存储会员信息
 int custNo [] = new int[5];
 String custBirth [] = new String[5];
 int custScore [] = new int[5];
public void showPay(){
//会员1号
 custNo[0] = 1623;
 custBirth[0] = "06/26";
 custScore[0] = 5000; 
//会员2号
 custNo[1] = 1624;
 custBirth[1] = "06/23";
 custScore[1] = 9000;  
//会员3号
 custNo[2] = 1625;
 custBirth[2] = "05/26";
 custScore[2] = 8000;
实现步骤如下:
(1)添加代码实现数据加载。
(2)编写带参数数的方法,实现会员折扣计算。
public double getDiscount(int curCustNo,int custNo[],int custScore[]){
         //根据会员号curCustNo查询对应的下标index
         //使用多重if结构判断折扣数目
         //使用return返回折扣值
}
求大侠完成的代码,谢谢。

解决方案 »

  1.   

    这难道是新手
    1.加载数据就是写一个入口,掉函数
    public static void main(String[] args) {
        Test t = new Test();
        t.showPay();}
    2.
    public double getDiscount(int curCustNo,int custNo[],int custScore[]){
    //根据会员号curCustNo查询对应的下标indexint index ;
    for(int i = 0 ; i<custNo.length ; i++){
    if(custNo[i] == curCustNo)
    index  = i ;
    }
      
                      //使用多重if结构判断折扣数目
    if(custScore[index]>5000)
    return 0.5d ;
    if(custScore[index]>5000)
    return 0.5d ;         //使用return返回折扣值
    }
      

  2.   

    没写完自己提交了 悲剧 
    2.
    public double getDiscount(int curCustNo,int custNo[],int custScore[]){
    //根据会员号curCustNo查询对应的下标indexint index ;
    for(int i = 0 ; i<custNo.length ; i++){
    if(custNo[i] == curCustNo)
    index  = i ;
    }
      
                      //使用多重if结构判断折扣数目
    if(custScore[index]>5000)
    return 0.5d ;
    if(custScore[index]<=5000)
    return 0.8d ;
    return 1.0d ;         //使用return返回折扣值
    }