import java.util.*;
public class CheckBook{
public static final String[] book = {"春天日记","高等数学","计算机概述","网络设计","论语","青春的躁动","大学英语"};
Scanner scanner = new Scanner(System.in);
public static void main(String[] args){
CheckBook checkBook = new CheckBook();
try{
checkBook.test1();
}catch(Exception e){
e.printStaceTrack();
}finally{
System.out.println("期待您的下次光临!");
}
}
public void test1()throws Exce {
while(true){
System.out.println("请输入您要查询的id:");
if(scanner.hasNextInt()){
int number = scanner.nextInt();
if(number>book.length || number<0){
throw new Exce("序号不存在!");
}else{
System.out.println("请输入书籍名称:");
String bookName = scanner.next();
if(bookName.equals(book[number-1])){
System.out.println("图书馆中有此书,书的序号为:"+number);
break;
}else{
throw new Exce("图书不存在!");
}
}
}else{
throw new Exce ("错误命令异常!");
}
}
}
weibo_快乐is魏帆_0
相关分类