总感觉哪里不对,谁帮忙看看
package com.book.borrow;
import java.util.Scanner;
public class BookLend {
public static void main(String[] args) {
// TODO 自动生成的方法存根
String book[] = {"物理","地理","化学","音乐","体育"};
Scanner input = new Scanner(System.in);
int in1;
String bookName;
int bookNum;
System.out.println("**********欢迎来到图书借阅系统**********");
do{
System.out.println("输入命令:1-按照名称查找图书;2-按照序号查找图书");
in1 = input.nextInt();
if(in1!=1&&in1!=2){
System.out.println("命令输入错误!请根据提示输入数字命令!");
continue;
}
if(in1==1){
System.out.println("请输入图书名称:");
bookName = input.next();
try{
for(String x:book) {
if(bookName.equals(x)){
System.out.println("book:"+bookName);
break;
}else{
throw new BookException(bookName);
}
}
}catch(BookException e){
System.out.println("您输入的图书不存在!");
in1=0;
continue;
}
}
if(in1==2){
System.out.println("请输入图书序号:");
bookNum = input.nextInt();
try{
if(bookNum>0&&bookNum<=book.length){
System.out.println("book:"+book[bookNum-1]);
break;
}else{
throw new BookException(bookNum);
}
}catch(BookException e){
System.out.println("您输入的图书不存在!");
in1=0;
continue;
}
}
}while(in1!=1&&in1!=2);
}
}