Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.36 KB | None | 0 0
  1. public class FinalOne {
  2.  
  3.  
  4. public static void main(String[] args) {
  5. {
  6. System.out.println("Amount Coins");
  7. while (true) {
  8. int amount = BIO.getInt();
  9.  
  10. int fullamount = amount;
  11. int twoHundredPCoin = 0;
  12. int oneHundredPCoin = 0;
  13. int fiftyPCoin = 0;
  14. int twentyPCoin = 0;
  15. int tenPCoin = 0;
  16. int fivePCoin = 0;
  17. int twoPCoin = 0;
  18. int onePCoin = 0;
  19. int coincounter = 0;
  20. String twohun_out = "";
  21. String onehuu_out = "";
  22. String fifty_out = "";
  23. String twinty_out = "";
  24. String ten_out = "";
  25. String five_out = "";
  26. String two_out = "";
  27. String one_out = "";
  28. if (amount > 500) {
  29.  
  30. break;
  31.  
  32. }
  33. if (amount < 1)
  34. {
  35. break;
  36. }
  37. else
  38. {
  39.  
  40.  
  41. while (amount >= 200) {
  42.  
  43. twoHundredPCoin = twoHundredPCoin + 1;
  44. amount = amount - 200;
  45. coincounter++;
  46.  
  47. }
  48.  
  49. while (amount >= 100) {
  50.  
  51. oneHundredPCoin = oneHundredPCoin + 1;
  52. amount = amount - 100;
  53. coincounter++;
  54. }
  55.  
  56. while (amount >= 50) {
  57.  
  58. fiftyPCoin = fiftyPCoin + 1;
  59. amount = amount - 50;
  60. coincounter++;
  61. }
  62.  
  63. while (amount >= 20) {
  64.  
  65. twentyPCoin = twentyPCoin + 1;
  66. amount = amount - 20;
  67. coincounter++;
  68. }
  69.  
  70. while (amount >= 10) {
  71.  
  72. tenPCoin = tenPCoin + 1;
  73. amount = amount - 10;
  74. coincounter++;
  75. }
  76.  
  77. while (amount >= 5) {
  78.  
  79. fivePCoin = fivePCoin + 1;
  80. amount = amount - 5;
  81. coincounter++;
  82. }
  83.  
  84. while (amount >= 2) {
  85.  
  86. twoPCoin = twoPCoin + 1;
  87. amount = amount - 2;
  88. coincounter++;
  89. }
  90.  
  91. while (amount >= 1) {
  92.  
  93. onePCoin = onePCoin + 1;
  94. amount = amount - 1;
  95. coincounter++;
  96. }
  97.  
  98. if (twoHundredPCoin >= 1) {
  99. if (twoHundredPCoin == 1) {
  100. twohun_out = "200p";
  101. } else
  102. twohun_out = twoHundredPCoin + "*200p";
  103. }
  104.  
  105. if (oneHundredPCoin >= 1) {
  106. if (oneHundredPCoin == 1) {
  107. onehuu_out = "100p";
  108. } else
  109. onehuu_out = oneHundredPCoin + "*100p";
  110. }
  111.  
  112. if (fiftyPCoin >= 1) {
  113. if (fiftyPCoin == 1) {
  114. fifty_out = " 50p";
  115. } else
  116. fifty_out = fiftyPCoin + "*50p";
  117. }
  118.  
  119. if (twentyPCoin >= 1) {
  120. if (twentyPCoin == 1) {
  121. twinty_out = " 20p";
  122. } else
  123. twinty_out = twentyPCoin + "*20p";
  124. }
  125.  
  126. if (tenPCoin >= 1) {
  127. if (tenPCoin == 1) {
  128. ten_out = " 10p";
  129. } else
  130. ten_out = tenPCoin + "*10p";
  131. }
  132. if (fivePCoin >= 1) {
  133. if (fivePCoin == 1) {
  134. five_out = " 5p";
  135. } else
  136. five_out = fivePCoin + "*5p";
  137. }
  138. if (twoPCoin >= 1) {
  139. if (twoPCoin == 1) {
  140. two_out = " 2p";
  141. } else
  142. two_out = twoPCoin + "*2p";
  143. }
  144. if (onePCoin >= 1) {
  145. if (onePCoin == 1) {
  146. one_out = " 1p";
  147. } else
  148. one_out = onePCoin + "*1p";
  149. }
  150. System.out.print((fullamount) + "p" + " " +
  151. coincounter + " coins "
  152. + twohun_out + " "
  153. + onehuu_out + " "
  154. + fifty_out + " "
  155. + twinty_out + " "
  156. + ten_out + " "
  157. + five_out + " "
  158. + two_out + " "
  159. + one_out + " ");
  160. }
  161. }
  162. }
  163. }
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement