aggressiveviking

Untitled

Feb 10th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.Coins
  4. {
  5. class Coins
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. double coinsInput = double.Parse(Console.ReadLine());
  11. double coinCount = 0;
  12. double coins = coinsInput * 100;
  13.  
  14. while (coins >= 1)
  15. {
  16. coinCount++;
  17.  
  18. if (coins >= 200)
  19. {
  20. double num = Math.Floor(coins / 100);
  21. double twoCoinsCount = Math.Floor(num / 2);
  22. double reminder = num % 2;
  23.  
  24. coinCount += twoCoinsCount;
  25. coinCount--;
  26.  
  27. coins %= 100;
  28.  
  29. coins = coins + (reminder * 100);
  30. }
  31. else if (coins >= 100)
  32. {
  33. coins -= 100;
  34. }
  35. else if (coins >= 50)
  36. {
  37. coins -= 50;
  38. }
  39. else if (coins >= 20)
  40. {
  41. coins -= 20;
  42. }
  43. else if (coins >= 10)
  44. {
  45. coins -= 10;
  46. }
  47. else if (coins >= 5)
  48. {
  49. coins -= 5;
  50. }
  51. else if (coins >= 2)
  52. {
  53. coins -= 2;
  54. }
  55. else if (coins >= 1)
  56. {
  57. coins -= 1;
  58. }
  59. }
  60.  
  61. Console.WriteLine(coinCount);
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment