为了账号安全,请及时绑定邮箱和手机立即绑定

大佬们帮我看看是哪里出错了呀

borrowBookjava.util.ScannerBorrowBook {
    (String[] args) {
        String[] bookList =String[]bookList[]=bookList[]=bookList[]=bookList[]=System..println()order=Scanner scanner=Scanner(System.){
            order=scanner.nextInt()}(Exception e){
            System..println()}
        (order){
            :
                System..println()String bookNamebookName=scanner.next(){
                    (i=i<= bookList.i++)String book=bookList.get(i)(bookName.equals(book)){
                        System..println(+book)}
                }(Exception e){
                    System..println()}
                :
                System..println()num={
                    num=scanner.nextInt()}(Exception e){
                    System..println()}
                {
                    System..println(+bookList.get(num-))}(Exception e){
                    System..println()}
                :
                System..println()}
    }
}


正在回答

1 回答

import java.util.Scanner; public class BorrowBook {    public static void main(String[] args) {        // 初始化图书列表        String[] bookList = {"Book1", "Book2", "Book3"};        Scanner scanner = new Scanner(System.in);        int order = 0;        try {            System.out.println("请输入操作序号:");            order = scanner.nextInt();        } catch (Exception e) {            System.out.println("输入有误:" + e.getMessage());        }        switch (order) {            case 1:                System.out.println("请输入要借阅的图书名称:");                String bookName = scanner.next();                try {                    for (int i = 0; i < bookList.length; i++) {                        String book = bookList[i];                        if (bookName.equals(book)) {                            System.out.println("借阅成功:" + book);                        }                    }                } catch (Exception e) {                    System.out.println("出现异常:" + e.getMessage());                }                break;            case 2:                System.out.println("请输入要借阅的图书序号:");                int num = 0;                try {                    num = scanner.nextInt();                } catch (Exception e) {                    System.out.println("输入有误:" + e.getMessage());                }                try {                    System.out.println("借阅成功:" + bookList[num - 1]);                } catch (Exception e) {                    System.out.println("出现异常:" + e.getMessage());                }                break;            default:                System.out.println("无效的操作序号");                break;        }        scanner.close();    } }

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

大佬们帮我看看是哪里出错了呀

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号