Guest User

Untitled

a guest
Oct 10th, 2018
811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Coins
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double change = double.Parse(Console.ReadLine());
  14. int numberCoins = 0;
  15. int coins = 0;
  16. change *= 100;
  17.  
  18. coins = (int)change / 200;
  19. change -= coins * 200;
  20. numberCoins += coins;
  21.  
  22. coins = (int)change / 100;
  23. change -= coins * 100;
  24. numberCoins += coins;
  25.  
  26. coins = (int)change / 50;
  27. change -= coins * 50;
  28. numberCoins += coins;
  29.  
  30. coins = (int)change / 20;
  31. change -= coins * 20;
  32. numberCoins += coins;
  33.  
  34. coins = (int)change / 10;
  35. change -= coins * 10;
  36. numberCoins += coins;
  37.  
  38. coins = (int)change / 5;
  39. change -= coins * 5;
  40. numberCoins += coins;
  41.  
  42. coins = (int)change / 2;
  43. change -= coins * 2;
  44. numberCoins += coins;
  45.  
  46. coins = (int)change / 1;
  47. change -= coins * 1;
  48. numberCoins += coins;
  49.  
  50. Console.WriteLine(numberCoins);
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment