继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

借书系统初级学习各位大神多指教

慕田峪7133559
关注TA
已关注
手记 3
粉丝 1
获赞 7

package jieshuxitong;

import java.util.Scanner;

public class jiashu {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.out.println("**********欢迎使用借书系统*************");
     Scanner input = new Scanner(System.in);
    while (true) {

        System.out.println("输入命令:1-按照名称查找图书;2-按照序号查找图书");
        try {
            switch (input.next()) {
            case "1":
                System.out.println("请输入图书名称:");
                try {
                    String c = input.next();
                    switch (c) {
                    case "chinese":
                        System.out.println("book:chinese");
                        break ;
                    case "mathematical":
                        System.out.println("book:mathematical");
                        break;
                    case "english":
                        System.out.println("book:english");
                        break;
                    default:
                        System.out.println("没有" + c + "图书");
                        continue;
                    }

                } catch (Exception e) {
                    // TODO: handle exception
                    Exception as = new Exception("请输入字符串!");
                    as.initCause(e);
                    throw as;
                }
            break;
            case "2":
                System.out.println("请输入图书序号:");
                try {
                    String g = input.next();
                    switch (g) {
                    case "1":
                        System.out.println("book:chinese");
                        break;
                    case "2":
                        System.out.println("book:mathematical");
                        break;
                    case "3":
                        System.out.println("book:english");
                        break;
                    default:
                        System.out.println("没有" + g + "图书");
                        continue;
                    }

                } catch (Exception e) {
                    // TODO: handle exception
                    Exception as = new Exception("请输入整数!");
                    as.initCause(e);
                    throw as;
                }
            break;
            default :
                System.out.println("输入不正确!");
                break;
            }
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println("输错了哈哈哈");
        }
    }
}

}

打开App,阅读手记
2人推荐
发表评论
随时随地看视频慕课网APP

热门评论

哈哈哈 真的是初学啊  加油

查看全部评论