java学生姓名录入查询系统

2022-07-21 07:55:19   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《java学生姓名录入查询系统》,欢迎阅读!
查询系统,录入,姓名,学生,java


package April;

import java.util.Scanner; public class B2 {

Scanner input = new Scanner(System.in); String []names=new String[30]; String answer=" ";

public void show(String name){ for(int i=0;i<names.length;i++){ if(names[i]==null){ names[i]=name; break; } } }

public void show1(){

System.out.println("******学生列表******"); for(int i=0;i<names.length;i++){


if(names[i]!=null){

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

public boolean findCustomer(String name){ boolean find = false; int i =0;

while(names[i] != null){ if(names[i].equals(name)){ find = true; break; } i++; }

return find; }

public static void main(String []args){ Scanner input = new Scanner(System.in); B2 xx=new B2();


do{

System.out.print("请输入学生的姓名:"); String name=input.next(); xx.show(name);

System.out.println("继续输入吗?(y/n)"); xx.answer =input.next(); }

while("y".equals(xx.answer)); xx.show1();

System.out.println(" ");

System.out.print("请输入要查找的学生姓名:"); String findname=input.next();

System.out.println("******查找结果******"); if(xx. findCustomer(findname)){ System.out.print("找到了!"); } else{

System.out.print("查无此人!"); } } }


本文来源:https://www.wddqxz.cn/b1441a9da6c30c2259019ef3.html

相关推荐