/* * * Title: TotalBills (prints the least number of bills) * written by Arthur Gapusan (ajgapusan@hotmail.com) * http://www.planet-java.biz.ly * * * example: java TotalBills 32012.50 * */ class TotalBills { public static void main(String args[]) { double m[] = {1000, 500, 200, 100, 50, 20, 10, 5, 1, .25, .10, .05}; double mn = Double.parseDouble(args[0]); int b = 0; for (int i = 0, f = 0;i<12;i++) { for (f = 0;mn>=m[i]; f++) mn -= m[i]; if (i>=10) mn+=.001; if (f>0) System.out.println(f + " x " + m[i]); b+=f; } System.out.println(b + " Bills"); } }