- import java.util.Scanner;
- public class moneycount
- {
- public static void main (String []args)
- {
- // define variables
- double Quarters;
- double Dimes;
- double Nickels;
- double Pennies;
- int twentydollar;
- int tendollar;
- int fivedollar;
- int dollar;
- // define the java line reader
- Scanner scan = new Scanner(System.in);
- System.out.println("please enter an amount of money");
- double money = scan.nextDouble();
- double total;
- System.out.println("this is how much you said " + money);
- // CASH
- twentydollar = ((int)money / 20);
- total = money - (twentydollar * 20);
- //System.out.println(total);
- tendollar = ((int)total / 10);
- total = total - (tendollar * 10);
- //System.out.println(total);
- fivedollar = ((int)total / 5);
- total = total - (fivedollar * 5);
- //System.out.println(total);
- dollar = ((int)total / 1);
- total = total - (dollar * 1);
- // Change
- System.out.println(total);
- Quarters = (total / 0.25);
- System.out.println(Quarters);
- total = ((total) - (Quarters * .25));
- System.out.println(total);
- System.out.println(Quarters);
- Dimes = (total / 0.10);
- total = total - (Dimes * 0.10);
- System.out.println(total);
- Nickels = (total / 0.05);
- total = total - (Nickels * 0.05);
- System.out.println(total);
- Pennies = (total / 0.01);
- total = total - (Pennies * 0.01);
- System.out.println(total);
- 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 ");
- }
- }
CountJAVA
By: microhaxo | Date: Jan 28 2009 02:14 | Format: None | Expires: never | Size: 1.69 KB | Hits: 1096
Latest pastes
57 minutes ago
10 hours ago
1 days ago
2 days ago
2 days ago