查找会员积分

package lei;


import java.util.Scanner;


/*--练习——查找会员积分 
 * 
 * 需求说明:
 *  循环输入多个会员的信息,根据会员编号,查找会员积分 
 * 
 */
public class testFind {
 public static void main(String[] args) {
Scanner in=new Scanner(System.in);
Customers s1=new Customers();
for(int i=0;i<2;i++){
Custome s2=new Custome();
System.out.print("输入会员编号:");
s2.number=in.nextInt();
System.out.print("输入会员积分:");
s2.integral=in.nextInt();
s1.add(s2);
}
s1.show();
System.out.print("请输入要查找的会员编号:");
int find=in.nextInt();
s1.find(find);

}
}


class Custome{//
int integral;//积分
int number;  //编号


}


class Customers{
Custome[] Customers=new Custome[100];

//添加
public void add(Custome cust){
for(int i=0;i if(Customers[i]==null){
Customers[i]=cust;
break;
}
}
}

//显示
public void show(){
System.out.println("***会员列表***");
System.out.println("编号\t积分");
for(int i=0;i if(Customers[i]!=null){
System.out.println(Customers[i].number+"\t"+Customers[i].integral);

}
}


}

//查找
public int find(int find){
for(int i=0;i if(Customers[i]!=null){
if(Customers[i].number==find){
System.out.println("该会员积分为:"+Customers[i].integral);
break;
}
}else {
System.out.println("没有该会员!!!");
break;
}

}

return find ;
}

}

你可能感兴趣的:(查找会员积分)