| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 545 人关注过本帖
标题:收银员找钱系统
只看楼主 加入收藏
卢静
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-4-27
结帖率:0
收藏
 问题点数:0 回复次数:0 
收银员找钱系统
package superMarket.expense.change;

public class T1 {
    int money1;// 顾客的钱
    int money2;// 超市的钱

    public void setMoney1(int money1) {
        this.money1 = money1;
        System.out.println("顾客支付金额为:" + money1);
    }

    public int getMoney1() {
        return money1;

    }

    public void setUseMoney2(int money2) {
        this.money2 = money2;
        System.out.println("您本次消费金额为:" + money2);
    }

    public int getUseMoney2() {
        return money2;

    }

    public static void main(String[] args) {
        T1 p = new T1();
        p.setMoney1(1000);
        p.getMoney1();
        // System.out.println(p.getMoney());
        p.setUseMoney2(369);
        p.getUseMoney2();
        int balance = p.getMoney1() - p.getUseMoney2();
        System.out.println("应找给顾客的金额:" + balance);
        int oneHundred = balance / 100;
        int ten = balance % 100 / 10;
        int one = balance % 100 % 10;
        System.out.println("一百元的" + oneHundred + "张");
        if (ten > 5) {
            System.out.println("五十元的 1张");
            System.out.println("二十元的" + ten % 5 / 2 + "张");
            System.out.println("十元的" + ten % 5 % 2 + "张");
        } else {
            if (ten >= 2) {
                System.out.println("二十元的" + ten / 2 + "张");
                System.out.println("十元的" + ten % 2 + "张");
            } else
                System.out.println("l元的" + ten + "张");

        }
        if (ten >= 5) {
            System.out.println("五元的 1张");
            System.out.println("两元的" + one % 5 / 2 + "张");
            System.out.println("一元的" + one % 5 % 2 + "张");
        } else {
            if (one >= 2) {
                System.out.println("两元的" + one / 2 + "张");
                System.out.println("l元的" + one % 2 + "张");
            } else
                System.out.println("l元的" + one + "张");

        }
    }
}
搜索更多相关主题的帖子: package public return 收银员 
2015-04-27 15:02
快速回复:收银员找钱系统
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029721 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved