public class Money { public static void main(String[] args) { Money m = new Money(); int cost=201; int cath=1000; int ralch=cath-cost; System.out.println("一百元:"+m.getMonet(ralch)); //用支付完100元以后的结果在计算50的应该找几张 ralch=ralch%100; System.out.println("50的:"+m.getfifty(ralch)); ralch=ralch%50; System.out.println("20元的找几张:"+m.getSecond(ralch)); ralch=ralch%20; System.out.println("10元的找几张:"+m.getTen(ralch)); ralch=ralch%10; System.out.println("5元的找几张:"+m.getfive(ralch)); ralch=ralch%5; System.out.println("2元的找几张:"+m.getTwo(ralch)); ralch=ralch%2; System.out.println("1元的找几张:"+m.getOne(ralch)); } public int getMonet(int s) { return s / 100; } public int getfifty(int f) { return f / 50; } public int getSecond(int g) { return g / 20; } public int getTen(int t) { return t / 10; } public int getfive(int v) { return v / 5; } public int getTwo(int w) { return w / 2; } public int getOne(int o){ return o/1; } }