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

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

交作業(yè)~~歡迎暴力測(cè)試,提出改進(jìn)。

package AA;


import java.util.Scanner;


public class Main {

? ? static String[] s = {"紅樓夢(mèng)","水滸傳","西游記","三國(guó)演義"};

public static void main(String[] args) {

select();

}

? ? public static void select(){

? ? System.out.println("請(qǐng)輸入命令:1-按照書(shū)籍名稱(chēng)查找書(shū)籍。2-按照書(shū)籍序號(hào)查找圖書(shū)");

? ? try{

? ? Scanner sc = new Scanner(System.in);

? ? ? ? int a = sc.nextInt();

? ? ? ? if(a == 1){ Name();

? ? ? ? }else if(a == 2){ Num();

? ? ? ? }else{

? ? ? ? System.out.println("你輸入的命令有誤!");

? ? ? ? select();

? ? ? ? }

? ? }catch(Exception e){

? ? e.printStackTrace();

? ? }

? ? }

? ? public static void Name(){

? ? System.out.println("請(qǐng)輸入圖書(shū)名稱(chēng):");

? ? try{

? ? Scanner sc = new Scanner(System.in);

? ? ? ? String x = sc.next();

? ? ? ? name(x);

? ? ? ? if(x.equals(s[0])){

? ? ? ? System.out.println("書(shū)籍:"+s[0]);

? ? ? ? System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

? ? ? ? int a = sc.nextInt();

? ? ? ? if(a == 1){ select(); }

? ? ? ? else{ System.out.println("歡迎下次光臨!"); }

? ? ? ? }else if(x.equals(s[1])){

? ? ? ? System.out.println("書(shū)籍:"+s[1]);

? ? ? ? System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

? ? ? ? int a = sc.nextInt();

? ? ? ? if(a == 1){ select(); }

? ? ? ? else{ System.out.println("歡迎下次光臨!"); }

? ? ? ? }else if(x.equals(s[2])){

? ? ? ? System.out.println("書(shū)籍:"+s[2]);

? ? ? ? System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

? ? ? ? int a = sc.nextInt();

? ? ? ? if(a == 1){ select(); }

? ? ? ? else{ System.out.println("歡迎下次光臨!"); }

? ? ? ? }else if(x.equals(s[3])){

? ? ? ? System.out.println("書(shū)籍:"+s[3]);

? ? ? ? System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

? ? ? ? int a = sc.nextInt();

? ? ? ? if(a == 1){ select(); }

? ? ? ? else{ System.out.println("歡迎下次光臨!"); }

? ? ? ? }else{

? ? ? ? System.out.println("此書(shū)不存在!");

? ? ? ? Name();

? ? ? ? }

? ? }catch(Exception e){

? ? System.out.println(e.getMessage());

? ? select();

? ? }

? ? }

? ? public static void Num(){

? ? System.out.println("請(qǐng)輸入圖書(shū)序號(hào):");

? ? try{

? ? Scanner sc = new Scanner(System.in);

? ? ? ? int y = sc.nextInt();

? ? ? ? num(y);

? ? if(y==0){

? ? System.out.println("book:"+s[0]);

? ? System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

int a = sc.nextInt();

if(a == 1){ select(); }

else{ System.out.println("歡迎下次光臨!"); }

? ? }

? ? else if(y==1){

? ? System.out.println("book:"+s[1]);

? ? System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

int a = sc.nextInt();

if(a == 1){ select(); }

else{ System.out.println("歡迎下次光臨!"); }

}

? ? else if(y==2){

? ? ? ? ? ?System.out.println("book:"+s[2]);

? ? ? ? ? ?System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

? ? ? ? ? ? ? ?int a = sc.nextInt();

? ? ? ? ? ? ? ?if(a == 1){

? ? ? ? ? ? ? ?select();

? ? ? ? ? ? }

? ? ? ? ? ? ? ?else{

? ? ? ? ? ? ? System.out.println("歡迎下次光臨!");

? ? ? ? ? ? }

? ? ? }

? ? else if(y==3){

? ? ? ? ? ? System.out.println("book:"+s[3]);

? ? ? ? ? ? System.out.println("是否繼續(xù)查找書(shū)籍?1-是。2-否");

? ? ? ? ? int a = sc.nextInt();

? ? ? ? ? if(a == 1){

? ? ? ? ? select();

? ? ? ? ? }

? ? ? ? ? else{

? ? ? ? ? System.out.println("歡迎下次光臨!");

? ? ? ? ? }

? ? ? ? }

? ? else{

? ? System.out.println("此序號(hào)不存在!");

? ? Num();

? ? }

? ? }catch(Exception e){

? ? System.out.println(e.getMessage());

? ? select();

? ? }

? ? }

? ? public static String name(String x)throws Exception{

? ? if(!(x.equals(s[0]))&&!(x.equals(s[1]))&&!(x.equals(s[2]))&&!(x.equals(s[3]))){

? ? throw new Exception("圖書(shū)不存在");

? ? }

? ? return x;

? ? }

? ? public static int num(int y)throws Exception{

? ? if(y<0||y>3){

? ? throw new Exception("圖書(shū)不存在");

? ? }

? ? return y;

? ? }

}


正在回答

1 回答

/***

1、循環(huán)體+return? 可以在用戶(hù)輸入錯(cuò)誤時(shí)可以在選擇輸入,退出時(shí)可以退出整個(gè)程序。

2、catch 出的錯(cuò)誤,我們提示“錯(cuò)誤”,不要用系統(tǒng)的錯(cuò)誤,用戶(hù)體驗(yàn)更好。

*/

?public static void select(){


? ? System.out.println("請(qǐng)輸入命令:1-按照書(shū)籍名稱(chēng)查找書(shū)籍。2-按照書(shū)籍序號(hào)查找圖書(shū)");

while(true){

try{


Scanner sc = new Scanner(System.in);


int a = sc.nextInt();


if(a == 1){ Name();

????return;? //退出


}else if(a == 2){ Num();

return; //退出


}else{


System.out.println("你輸入的命令有誤!");


//select();


}


}catch(Exception e){


//e.printStackTrace();

System.out.println("請(qǐng)輸入1、2選擇操縱");

}


}

}


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

舉報(bào)

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

Java中你必須懂得常用技能,不容錯(cuò)過(guò)的精彩,快來(lái)加入吧

進(jìn)入課程

交作業(yè)~~歡迎暴力測(cè)試,提出改進(jìn)。

我要回答 關(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)