交作業(yè)交作業(yè)拉?。?!
package jieshu;
import java.util.*;
public class xinxi {
? ? public static String []shuji=new String[] {"1.高數(shù)","2.離散","3.軟件工程"};
public static int haoma=0;
public static void show(){
Scanner in=new Scanner(System.in);
String name;
int i;
System.out.println("請輸入要查詢類型的代碼:1.按照書名、2.按照圖書序號");
try {
do {
i=in.nextInt();
switch(i) {
case 1:? System.out.println("請輸入書名");
? ? ? ? ?name=in.next();
? ? ? ? ?switch(name) {
? ? ? ? ?case "高數(shù)":System.out.println("book: 1.高數(shù)");break;
? ? ? ? ?case "離散":System.out.println("book: 2.離散");break;
? ? ? ? ?case "軟件工程":System.out.println("book:3.軟件工程");break;
? ? ? ? ?default:System.out.println("圖書不存在");
System.out.println("請重新輸入書名");break;
? ? ? ? ?}break;
case 2:? System.out.println("請輸入圖書序號");
? ? ? ? ?do {
? ? ? ? ?haoma=in.nextInt();
? ? ? ? ?switch(haoma) {
? ? ? ? ?case 1: System.out.println("book: 1.高數(shù)");break;
? ? ? ? ?case 2: System.out.println("book: 2.離散");break;
? ? ? ? ?case 3: System.out.println("book:3.軟件工程");break;
? ? ? ? ?default:System.out.println("圖書不存在");
System.out.println("請重新輸入圖書序號");break;
? ? ? ? ?}
? ? ? ? ?}while(haoma!=1&&haoma!=2&&haoma!=3);
? ? ? ? ?break;
default:System.out.println("輸入錯誤,請按照提示輸入");break;
}
}while(i!=1&&i!=2);
}catch(Exception e) {
e.printStackTrace();
System.out.println("出錯啦?。。。?!");
System.out.println("請及時更正錯誤哦!?。?);
}finally {
}
}
public static void main(String[] args) {
// TODO 自動生成的方法存根
? ? xinxi xi=new xinxi();
? ??
xi.show();
}
}
2020-07-23
你這不對啊,書名輸入錯誤之后,你這后面沒法繼續(xù)進行下去了