import java.util.Scanner;
public class TEST {
public static void main(String[] args) {
String[] str={"语文","数学","外语","政治","历史","地理","体育","音乐","物理","化学"};
Scanner san=new Scanner(System.in);
System.out.println("********欢迎进入图书查询系统********");
System.out.println("1、按图书名查找 2、按图书序号查找");
try {
int score=san.nextInt();
if(score==1){
try {
System.out.println("请输入书名:");
String score1=san.next();
for(int i=0;i<str.length;i++){
if(str[i].contains(score1)){
System.out.println("Book"+str[i]);
san.close();
return;
}
}
System.out.println("图书名为【"+score1+"】的图书不存在!");
main(str);
} catch (Exception e) {
System.out.println("书名输入错误!");
main(str);
}
}else if(score==2){
try {
System.out.println("请输入序号(数字):");
int score1=san.nextInt();
if(score1>str.length-1){
System.out.println("序号为"+score1+"的图书不存在!");
main(str);
}else{
for(int i=0;i<str.length;i++){
if(score1==i){
System.out.println("Book"+str[i]);
san.close();
return;
}
}
}
} catch (Exception e) {
System.out.println("序号输入错误!");
main(str);
}
}else if(score!=1||score!=2){
System.out.println("请按提示输入!");
main(str);
}
} catch (Exception e) {
System.out.println("请按提示输入!");
main(str);
}
}
}