模擬借書系統(tǒng)
標(biāo)簽:
import java.util.Scanner;
public class TEST {
public static void main(String[] args) {
String[] str={"语文","数学","外语","政治","历史","地理","体育","音乐","物理","化学"};
Scanner san=new Scanner(System.in);
System.out.println("********欢迎进入图书查询系统********");
System.out.println("1、按图书名查找 2、按图书序号查找");
try {
int score=san.nextInt();
if(score==1){
try {
System.out.println("请输入书名:");
String score1=san.next();
for(int i=0;i<str.length;i++){
if(str[i].contains(score1)){
System.out.println("Book"+str[i]);
san.close();
return;
}
}
System.out.println("图书名为【"+score1+"】的图书不存在!");
main(str);
} catch (Exception e) {
System.out.println("书名输入错误!");
main(str);
}
}else if(score==2){
try {
System.out.println("请输入序号(数字):");
int score1=san.nextInt();
if(score1>str.length-1){
System.out.println("序号为"+score1+"的图书不存在!");
main(str);
}else{
for(int i=0;i<str.length;i++){
if(score1==i){
System.out.println("Book"+str[i]);
san.close();
return;
}
}
}
} catch (Exception e) {
System.out.println("序号输入错误!");
main(str);
}
}else if(score!=1||score!=2){
System.out.println("请按提示输入!");
main(str);
}
} catch (Exception e) {
System.out.println("请按提示输入!");
main(str);
}
}
}
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評論
評論
共同學(xué)習(xí),寫下你的評論
評論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦