 CountJAVA
By: microhaxo | Date: Jan 28 2009 02:14 | Format: None | Expires: never | Size: 1.69 KB | Hits: 950

1. import java.util.Scanner;
2. public class moneycount
3. {
4.         public static void main (String []args)
5.         {
6.         // define variables
7.         double Quarters;
8.         double Dimes;
9.         double Nickels;
10.         double Pennies;
11.         int twentydollar;
12.         int tendollar;
13.         int fivedollar;
14.         int dollar;
15.         // define the java line reader
16.         Scanner scan = new Scanner(System.in);
17.         System.out.println("please enter an amount of money");
18.         double money = scan.nextDouble();
19.         double total;
20.         System.out.println("this is how much you said " + money);
21.         // CASH
22.         twentydollar = ((int)money / 20);
23.         total = money - (twentydollar * 20);
24.         //System.out.println(total);
25.         tendollar = ((int)total / 10);
26.         total = total - (tendollar * 10);
27.         //System.out.println(total);
28.         fivedollar = ((int)total / 5);
29.         total = total - (fivedollar * 5);
30.         //System.out.println(total);
31.         dollar = ((int)total / 1);
32.         total = total - (dollar * 1);
33.
34.         // Change
35.         System.out.println(total);
36.
37.         Quarters = (total / 0.25);
38.
39.         System.out.println(Quarters);
40.
41.         total = ((total) - (Quarters * .25));
42.
43.         System.out.println(total);
44.
45.         System.out.println(Quarters);
46.
47.
48.
49.         Dimes = (total / 0.10);
50.         total = total - (Dimes * 0.10);
51.         System.out.println(total);
52.
53.         Nickels = (total / 0.05);
54.         total = total - (Nickels * 0.05);
55.         System.out.println(total);
56.
57.         Pennies = (total / 0.01);
58.         total = total - (Pennies * 0.01);
59.         System.out.println(total);
60.
61.         System.out.println(twentydollar + " twenty dollar bills " + "n" + tendollar  + " ten dollar bills "+ "n" + fivedollar + " fivedollar bills " + "n" + dollar + " one dollar bills  " + "n" + (int)Quarters + " Quarters " + "n" + (int)Dimes + " Dimes " + "n" + (int)Nickels + " Nickels " + "n" + (int)Pennies + " Pennies ");
62.         }
63. }