Java客栈系统小练习

Java客栈系统小练习,第1张

Java客栈系统小练习
package 课后作业;

import java.util.Scanner;


public class 新龙门客栈系统 {
    public static void main(String[] args) {
        System.out.print("n");
        System.out.print("新龙门客栈系统n");
        System.out.print("1.大床房 188元/间n");
        System.out.print("2.标间 288元/间n");
        System.out.print("3.三人房 388元/间n");
        System.out.print("4.总统套房 488元/间n");
        System.out.print("5.系统退出n");
        System.out.print("n");
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入所选类型的房间序号:");
        int Serialnumber = scanner.nextInt();
        while(Serialnumber<1||Serialnumber>5)
        {
            System.out.println("您输入有误请重新输入!");
            Serialnumber = scanner.nextInt();
        }
        double price=0;
        switch (Serialnumber)
        {
            case 1:
                price=188;
                break;
            case 2:
                price=288;
                break;
            case 3:
                price=388;
                break;
            case 4:
                price=488;
                break;
            case 5:
                scanner.close();
        }
        System.out.print("请输入房间数量:");
        int number = scanner.nextInt();
        double money = price * number;
        System.out.println("实收金额:"+money);
        System.out.println("请付款:");
        double amount = scanner.nextDouble();
        if (amount < money) {
            System.out.println("没钱不要睡霸王觉");
        } else {
            double give = amount - money;
            System.out.println("房间序号:" + Serialnumber + "数量" + number + "应收金额" + money + "实收金额" + amount + "找零" + give);
            scanner.close();
        }
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5437589.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存