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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

輸入1,然后進(jìn)入根據(jù)名稱(chēng)查找圖書(shū)的時(shí)候,例如,輸入 高數(shù) ,為什么查不到???

package?com.imooc_1;

import?java.util.Scanner;

public?class?BorrowBooks?{
	public?static?Scanner?sc?=?new?Scanner(System.in);
	/**
	?*?@param?args
	?*/
	public?static?void?main(String[]?args)?{
		//?TODO?Auto-generated?method?stub
		String[]?name?=?{"數(shù)據(jù)結(jié)構(gòu)","大學(xué)英語(yǔ)","高數(shù)","網(wǎng)絡(luò)工程","軟件工程","毛概"};
		
		
		while(true){
			System.out.println("輸入命令:1-按照名稱(chēng)查找圖書(shū);2-按照序號(hào)查找圖書(shū)");
			String?book;
			try{
				int?input?=?print();
				switch(input){
					case?1:
						book?=?getBookByName(name);
						System.out.println("book:"+book);
						break;
					case?2:
						book?=?getBookByNum(name);
						System.out.println("book:"+book);
						break;
					case?-1:
						System.out.println("命令輸入錯(cuò)誤!請(qǐng)根據(jù)提示輸入數(shù)字命令!");
						sc?=?new?Scanner(System.in);
						continue;
					default:
						System.out.println("命令輸入錯(cuò)誤!");
						continue;
				}
				break;
			}catch(Exception?e){
				System.out.println(e.getMessage());
				continue;
			}
		}
	}
	//按照?qǐng)D書(shū)名稱(chēng)查找
	public?static?String?getBookByName(String[]?nameBooks)?throws?Exception{
		System.out.println("請(qǐng)輸入圖書(shū)名稱(chēng):");
		String?nameSearch?=?sc.next();
		
		for(int?i=0;?i<nameBooks.length;?i++){
			if(nameSearch.equals(nameBooks[i]))
				return?nameBooks[i];
		}
		throw?new?Exception("圖書(shū)不存在!");
	}
	//按照?qǐng)D書(shū)序號(hào)查找
	public?static?String?getBookByNum(String[]?namebooks)?throws?Exception{
		while(true){
			System.out.println("請(qǐng)輸入圖書(shū)序號(hào):");
			int?num?=?print();
			try{
				if(num?==?-1){
					System.out.println("命令輸入錯(cuò)誤!請(qǐng)根據(jù)提示輸入數(shù)字命令!");
					continue;
				}
				String?book?=?namebooks[num-1];
				return?book;
			}catch(Exception?e){
				return?"圖書(shū)不存在";
			}
		}
	}
	//輸入命令,輸入圖書(shū)序號(hào)
	public?static?int?print(){
		int?x;
		try?{
			x?=?sc.nextInt();
			return?x;
		}?catch?(Exception?e)?{
			//?TODO:?handle?exception
			
			return?-1;
		}
	}
}


正在回答

3 回答

我也是這種情況,必須把鼠標(biāo)移到下一行才行

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

我記得輸入中文容易出問(wèn)題,最好是把要輸入的字復(fù)制過(guò)去。

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

http://img1.sycdn.imooc.com//57112fc90001e7e102610090.jpg

雖然不知道什么問(wèn)題,但是輸入時(shí)光標(biāo)移到下一行輸入就能正確顯示了。

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

青鋒qf 提問(wèn)者

對(duì)啊,這是什么情況
2016-04-16 回復(fù) 有任何疑惑可以回復(fù)我~
#2

森特 回復(fù) 青鋒qf 提問(wèn)者

_(:з」∠)_我也好好奇,如果有人知道請(qǐng)務(wù)必順便艾特我
2016-04-16 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

輸入1,然后進(jìn)入根據(jù)名稱(chēng)查找圖書(shū)的時(shí)候,例如,輸入 高數(shù) ,為什么查不到???

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

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

幫助反饋 APP下載

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

公眾號(hào)

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