package?com.xesivo;
import?java.util.Scanner;
public?class?MSLibrary?{
static?int?consent1?=?0;
static?int?consent2?=?0;
static?int?imput?=?0;
public?static?void?methSel()?throws?Exception{
Scanner?in?=?new?Scanner(System.in);
int?a?=?in.nextInt();
if(a?!=?1){
if(a?!=?2){
Exception?e?=?new?Exception();
throw?e;
}
}
imput?=?a;
consent1?=?1;
}
public?static?void?numSe()?throws?Exception{
Scanner?in?=?new?Scanner(System.in);
int?a?=?in.nextInt();
if(a?<?0){
Exception?e?=?new?Exception();
throw?e;
}
if(a?>?8){
Exception?e?=?new?Exception();
throw?e;
}
for(int?i?=?1;?i?<=?8;?i++){
if(i?==?a){
System.out.print("找到圖書(shū):");
switch(i){
case?1:
System.out.println("孟子");
break;
case?2:
System.out.println("山海經(jīng)");
break;
case?3:
System.out.println("說(shuō)文解字");
break;
case?4:
System.out.println("一生最?lèi)?ài)唐詩(shī)");
break;
case?5:
System.out.println("一生最?lèi)?ài)宋詞");
break;
case?6:
System.out.println("丁丁歷險(xiǎn)記全英");
break;
case?7:
System.out.println("哈利波特全英");
break;
case?8:
System.out.println("英國(guó)學(xué)生文學(xué)讀本");
break;
}
}
}
consent2?=?1;
}
public?static?void?nameSe()?throws?Exception{
Scanner?in?=?new?Scanner(System.in);
String?a?=?in.nextLine();
if(a?!=?"孟子"){
if(a?!=?"山海經(jīng)"){
if(a?!=?"說(shuō)文解字"){
if(a?!=?"一生最?lèi)?ài)唐詩(shī)"){
if(a?!=?"一生最?lèi)?ài)宋詞"){
if(a?!=?"丁丁歷險(xiǎn)記全英"){
if(a?!=?"哈利波特全英"){
if(a?!=?"英國(guó)學(xué)生文學(xué)讀本"){
Exception?e?=?new?Exception();
throw?e;
}
}
}
}
}
}
}
}
int?b?=?0;
switch(a){
case?"孟子":
b?=?1;
break;
case?"山海經(jīng)":
b?=?2;
break;
case?"說(shuō)文解字":
b?=?3;
break;
case?"一生最?lèi)?ài)唐詩(shī)":
b?=?4;
break;
case?"一生最?lèi)?ài)宋詞":
b?=?5;
break;
case?"丁丁歷險(xiǎn)記全英":
b?=?6;
break;
case?"哈利波特全英":
b?=?7;
break;
case?"英國(guó)學(xué)生文學(xué)讀本":
b?=?8;
break;
}
for(int?i?=?1;?i?<=?8;?i++){
if(i?==?b){
System.out.print("找到圖書(shū):");
switch(i){
case?1:
System.out.println("孟子");
break;
case?2:
System.out.println("山海經(jīng)");
break;
case?3:
System.out.println("說(shuō)文解字");
break;
case?4:
System.out.println("一生最?lèi)?ài)唐詩(shī)");
break;
case?5:
System.out.println("一生最?lèi)?ài)宋詞");
break;
case?6:
System.out.println("丁丁歷險(xiǎn)記全英");
break;
case?7:
System.out.println("哈利波特全英");
break;
case?8:
System.out.println("英國(guó)學(xué)生文學(xué)讀本");
break;
}
}
}
imput?=?b;
consent2?=?1;
}
public?static?void?main(String[]?args)?{
System.out.println("歡迎來(lái)到小粟圖書(shū)館!");
System.out.println("按序號(hào)查找圖書(shū)請(qǐng)按1,按名稱(chēng)查找圖書(shū)請(qǐng)按2!");
while(consent1?==?0){
try{
????methSel();
????}catch(Exception?e){
????System.out.println("輸入有誤,請(qǐng)重新輸入!");
????}
}
if(imput?==?1){
System.out.println("請(qǐng)輸入序號(hào)!");
while(consent2?==?0){
try{
numSe();
}catch(Exception?e){
????System.out.println("輸入有誤,請(qǐng)重新輸入!");
}
}
}
if(imput?==?2){
System.out.println("請(qǐng)輸入名稱(chēng)!");
while(consent2?==?0){
try{
nameSe();
}catch(Exception?e){
System.out.println("輸入有誤,請(qǐng)重新輸入!");
}
}
}
}
}運(yùn)行結(jié)果是這樣的嚶嚶嚶為什么?
添加回答
舉報(bào)
0/150
提交
取消