第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

求個大神指出錯誤...

import java.util.InputMismatchException;
import java.util.Scanner;
public class Book {

?public String books[]={"物理","化學(xué)","歷史","政治"};
?public static void main(String[] args) {
??Book Use=new Book();
??Use.test();
??
??
??// TODO Auto-generated method stub

?}
public? void test(){
Scanner input=new Scanner(System.in);
System.out.println("輸入命令:1-按照名稱查找圖書;2-按照序號查找圖書");
try{
?int a=input.nextInt();
?switch(a){
?case 1:
? System.out.println("請輸入圖書名稱");
? Scanner as=new Scanner(System.in);
? String name=as.next();
??? for(int i=0;i<books.length;i++){
???????? if(books[i].equals(name)){?
???? ?? System.out.println("book:"+books[i]);
???? ??? test();
????? }
??? }
???? ? System.out.println("圖書不存在,請重新輸入");
??? test();
?case 2:
??System.out.println("請輸入圖書序號");
??try{
??int d=input.nextInt();
??for(int i=0;i<books.length;i++){
???if(d==i+1){
???System.out.println("book"+books[i]);?
???}
??}
??test();
??}catch(InputMismatchException d ){
???System.out.println("輸入有誤,請輸入正確的圖書序號");
???test();
??}
?
?}
?
}catch(Exception e){
?System.out.println("命令輸入錯誤!請根據(jù)提示輸入數(shù)字命令");
?test();
}
?
}
?
}

http://img1.sycdn.imooc.com//55c317660001f1f514400874.jpg

正在回答

2 回答

樓主的問題是啥?在我這運(yùn)行的沒有報(bào)錯?。?/p>

0 回復(fù) 有任何疑惑可以回復(fù)我~
package?com.pun;
import?java.util.InputMismatchException;
import?java.util.Scanner;
public?class?Book?{



	public?static?void?main(String[]?args)?{
		Book?Use=new?Book();
		Use.test();


		//?TODO?Auto-generated?method?stub
	}
	public??void?test(){
		String[]?books={"物理","化學(xué)","歷史","政治"};
		Scanner?input=new?Scanner(System.in);
		System.out.println("輸入命令:1-按照名稱查找圖書;2-按照序號查找圖書");?
		try{
			int?a=input.nextInt();
			switch(a){
			case?1:
				System.out.println("請輸入圖書名稱");
				Scanner?as=new?Scanner(System.in);
				String?name=as.next();
				for(int?i=0;i<books.length;i++){
					if(books[i].equals(name)){??
						System.out.println("book:"+books[i]);?
						test();
					}
				}
				System.out.println("圖書不存在,請重新輸入");?
				test();
			case?2:
				System.out.println("請輸入圖書序號");
				try{
					int?d=input.nextInt();
					for(int?i=0;i<books.length;i++){
						if(d==i+1){
							System.out.println("book"+books[i]);?
						}
					}
					test();
				}catch(InputMismatchException?d?){
					System.out.println("輸入有誤,請輸入正確的圖書序號");
					test();
				}

			}

		}catch(Exception?e){
			System.out.println("命令輸入錯誤!請根據(jù)提示輸入數(shù)字命令");
			test();
		}

	}

}


1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Java入門第三季
  • 參與學(xué)習(xí)       409765    人
  • 解答問題       4543    個

Java中你必須懂得常用技能,不容錯過的精彩,快來加入吧

進(jìn)入課程

求個大神指出錯誤...

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號