Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Coins_MyTry
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. decimal change = decimal.Parse(Console.ReadLine());
  10. change = change * 100;
  11. decimal coins = 0;
  12. decimal dveSt = 0;
  13. decimal dvadesetSt = 0;
  14. while (change > 0)
  15. {
  16. decimal dvaLeva = Math.Truncate(change / 200);
  17. if (change >= 200)
  18. {
  19. if(dvaLeva==1)
  20. {
  21. coins++;
  22. change -= 200;
  23. }
  24. }
  25.  
  26.  
  27. if (change >= 100)
  28. {
  29. decimal edinLev = Math.Truncate(change / 100);
  30. if(edinLev==1)
  31. {
  32. coins++;
  33. change -= 100;
  34. }
  35. }
  36. if (change >=50)
  37. {
  38. decimal petdesetSt = Math.Truncate(change / 50);
  39. if(petdesetSt==1)
  40. {
  41. coins++;
  42. change -= 50;
  43. }
  44. }
  45. if (change >=20)
  46. {
  47. dvadesetSt = Math.Truncate(change / 20);
  48. if(dvadesetSt==1)
  49. {
  50.  
  51. change -= 20;
  52. }
  53. else if (dvadesetSt == 2)
  54. {
  55.  
  56. change -= 40;
  57. }
  58. }
  59. if (change >=10)
  60. {
  61. decimal desetSt = Math.Truncate(change / 10);
  62. if(desetSt==1)
  63. {
  64. coins++;
  65. change -= 10;
  66. }
  67. }
  68. if (change >=5)
  69. {
  70. decimal petSt = Math.Truncate(change / 5);
  71. if(petSt==1)
  72. {
  73. coins++;
  74. change -= 5;
  75. }
  76. }
  77. if (change >=2)
  78. {
  79. dveSt = Math.Truncate(change / 2);
  80. if(dveSt==1)
  81. {
  82.  
  83. change -= 2;
  84. }
  85. else if (dveSt == 2)
  86. {
  87.  
  88. change -= 4;
  89. }
  90. }
  91. if (change > 0)
  92. {
  93.  
  94. coins++;
  95. break;
  96. }
  97.  
  98. }
  99. Console.WriteLine(coins+dveSt+dvadesetSt);
  100. }
  101.  
  102.  
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement