package com.imooc.bookrent;
import java.util.Scanner;
public class BookRent {
static String[] books=new String[80];
static int b=0;
public void test1(){
System.out.println("请选择查书方式:输入1.序号 输入2.书名");
do{
try {
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
if(x==1){
System.out.println("请输入图书序号:");
b=x;
break;
}else if(x==2){
System.out.println("请输入书名:");
b=x;
break;
}else{
System.out.println("请输入有效数字:");
continue;
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("输入有误!请重新输入:");
continue;
}
}while(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
BookRent bk=new BookRent();
bk.test1();
do{
Scanner sc=new Scanner(System.in);
try{
if(b==1){
int n=sc.nextInt();
System.out.println("租书:"+books[n]);
}
}catch(Exception e){
System.out.println("不存在该图书,请重新输入:");
continue;
}
if(b==2){
String n=sc.nextLine();
System.out.println("租书:"+n);
}
}while(true);
}
}
點(diǎn)擊查看更多內(nèi)容
2人點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫(xiě)下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦