查找客户姓名JAVA,java-第十三章-类的无参方法(一)-查找客户姓名

package 上机练习;

public class A02class {

String names[] = new String[30];

public void showA(String name) {

for (int i = 0; i 

if (names[i] == null) {

names[i] = name;

break;

}

}

}

public void showB() {

System.out.println("\t客户列表显示");

for (int i = 0; i 

if (names[i] != null) {

System.out.print(names[i] + "\t");

}

}

}

public boolean showC(String find) {

boolean con = false;

for (int i = 0; i 

if (names[i] != null) {

if (names[i].equals(find)) {

con = true;

break;

}

}

}

return con;

}

}

package 上机练习;

import java.util.Scanner;

public class A02 {

public static void main(String[] args) {

// TODO Auto-generated method stub

A02class A02 = new A02class();

Scanner in = new Scanner(System.in);

boolean con = true;

while (con) {

System.out.println("请输入客户的姓名:");

String admin = in.next();

A02.showA(admin);

System.out.println("请输入是否继续:(y / n ):");

String choice = in.next();

if (choice.equals("n")) {

con = false;

break;

}

}

A02.showB();

System.out.println("请输入要查找的客户的姓名:");

String find = in.next();

if (A02.showC(find)) {

System.out.println("有");

} else {

System.out.println("没有");

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值