Advertisement
Rayk

Untitled

Feb 28th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Program
  5. {
  6. public static void Main()
  7. {
  8. int change = (int)(double.Parse(Console.ReadLine()) * 100);
  9.  
  10. int one = 1;
  11. int two = 2;
  12. int five = 5;
  13. int ten = 10;
  14. int twenty = 20;
  15. int fifty = 50;
  16. int oneHundred = 100;
  17. int twoHundred = 200;
  18.  
  19. int counter = 0;
  20.  
  21. while (change > 0)
  22. {
  23. int currentCoin;
  24.  
  25. if (change >= twoHundred)
  26. {
  27. currentCoin = twoHundred;
  28. }
  29. else if (change >= oneHundred)
  30. {
  31. currentCoin = oneHundred;
  32. }
  33. else if (change >= fifty)
  34. {
  35. currentCoin = fifty;
  36. }
  37. else if (change >= twenty)
  38. {
  39. currentCoin = twenty;
  40. }
  41. else if (change >= ten)
  42. {
  43. currentCoin = ten;
  44. }
  45. else if (change >= five)
  46. {
  47. currentCoin = five;
  48. }
  49. else if (change >= two)
  50. {
  51. currentCoin = two;
  52. }
  53. else
  54. {
  55. currentCoin = one;
  56. }
  57.  
  58. change -= currentCoin;
  59.  
  60. counter++;
  61. }
  62.  
  63. Console.WriteLine(counter);
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement