Guest User

Untitled

a guest
Jun 25th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. double amount = 27.65;
  2. int num20, num10, num5, num2, num1, num50c, num20c, num10c = 0;
  3.  
  4. do {
  5.     if (amount - 20 >= 0) { //check to see that you can subtract the denomination
  6.         //shorthand for subtracts 20 from amount and assigns it to amount, same as using amount = amount - 20;
  7.         amount -= 20;
  8.         num20++; //Increments num20 by 1;
  9.     } else { //If you can't subtract, then leave the loop.
  10.         break; //breaks out of the do-while loop;
  11.     }
  12. } while (1==1); //keeps the loop running (because 1 always equals 1) - hint there's a better way of doing it.
  13.  
  14. do {
  15.     if (amount - 10 >= 0) { //check to see that you can subtract the denomination
  16.         //shorthand for subtracts 10 from amount and assigns it to amount, same as using amount = amount - 10;
  17.         amount -= 10;
  18.         num10++; //Increments num10 by 1;
  19.     } else { //If you can't subtract, then leave the loop.
  20.         break; //breaks out of the do-while loop;
  21.     }
  22. } while (1==1); //keeps the loop running (because 1 always equals 1) - hint there's a better way of doing it.
  23.  
  24. System.out.println("$20: " + num20 + etc,etc,etc)
Add Comment
Please, Sign In to add comment