package com.imooc;
import java.util.Scanner;
public class Book {
static String[] name={new String("大学"),new String("中庸"),
new String("论语"),new String("孟子")};
static int[] num={1,2,3,4};
public static void main(String[] args) {
System.out.println("1-按照名称查找图书;2-按照序号查找图书");
Scanner input=new Scanner(System.in);
int score=input.nextInt();
boolean bl=true;
while(bl){
try{
while(score==1){
System.out.println("输入图书名称");
String bookname = input.next();
int i=0;
if(bookname.equals(name[i])){
System.out.println("book:"+name[i]);
bl=false;
i++;
break;
}
}
while(score==2){
System.out.println("输入图书序号");
int booknum=input.nextInt();
if(booknum==num[booknum-1]){
System.out.println("book:"+name[booknum-1]);
bl=false;
break;
}
}
}catch(Exception e){
System.out.println("图书不存在,请重新输入");
}
}
}
}
慕的地6079101
风信子it
HansonQ
司风0
羽觞丨醉月
相关分类