Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class atm {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int hundred = 0, fifty = 0, twenty = 0, tens = 0, fives = 0, ones = 0;
  8.  
  9.  
  10. System.out.println("Please Enter the amount you want to withdraw.");
  11. int withdraw = scan.nextInt();
  12.  
  13. while (withdraw != 0) {
  14. if (withdraw / 100 > 0) {
  15. hundred = (withdraw / 100);
  16. withdraw = withdraw % 100;
  17. System.out.println("Hello world");
  18. if (withdraw / 50 > 0) {
  19. fifty = (int)(withdraw / 50);
  20. withdraw = withdraw % 50;
  21. System.out.println("hello3");
  22. if (withdraw / 20 > 0) {
  23. twenty = (int)(withdraw / 20);
  24. withdraw = withdraw % 20;
  25. System.out.println("hello4");
  26. if (withdraw / 10 > 0) {
  27. tens = (int)(withdraw / 10);
  28. withdraw = withdraw % 10;
  29. System.out.println("hello5");
  30. if (withdraw / 5 > 0) {
  31. fives = (int)(withdraw / 5);
  32. withdraw = withdraw % 5;
  33. if (withdraw > 0) {
  34. ones = (int)(withdraw / 1);
  35. withdraw = withdraw % 1;
  36.  
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }
  44. System.out.println("You have recieved " + hundred + " hundreds\n "
  45. + fifty + " fiftys\n "
  46. + twenty + " twenties\n "
  47. + tens + " tens\n "
  48. + fives + " fives\n "
  49. + ones + " ones\n");
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement