Advertisement
Stan0033

Untitled

Apr 16th, 2021
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. using System;
  2.  
  3. namespace coins
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. { //------------------------------------------------
  9. string Change_as_text = Console.ReadLine();
  10. double change = double.Parse(Change_as_text);
  11. //------------------------------------------------
  12. int hundreds = 0;
  13. int tens = 0;
  14. int ones = 0;
  15. int twos = 0;
  16. int twenties = 0;
  17. int fives = 0;
  18. int fifties = 0;
  19. //------------------------------------------------
  20.  
  21. double Decimal_Part = change - ((int)change);
  22. string Decimal_as_Text = Decimal_Part.ToString("F2");
  23. if (Decimal_as_Text.Length == 3) { Decimal_Part *= 10; }
  24. if (Decimal_as_Text.Length == 4) { Decimal_Part *= 100; }
  25. int Decimal_Int = (int)Decimal_Part;
  26. string Decimal_Final = Convert.ToString(Decimal_Int);
  27.  
  28.  
  29. int calc;
  30.  
  31. //Console.WriteLine(Decimal_as_Text);
  32.  
  33.  
  34.  
  35.  
  36. if (Decimal_Final.Length >= 1)
  37. {
  38.  
  39. //------------------------------------------------
  40.  
  41. calc = Convert.ToInt32(Convert.ToString(Decimal_Final[0])); // get the first digit of the decimal
  42. // Console.WriteLine(calc);
  43. if (calc == 1) { tens++; }
  44. if (calc == 2) { twenties++; }
  45. if (calc == 3) { twenties++; tens++; }
  46. if (calc == 4) { twenties += 2; }
  47. if (calc == 5) { fifties++; }
  48. if (calc == 6) { fifties++; tens++; }
  49. if (calc == 7) { fifties++; twenties++; }
  50. if (calc == 8) { fifties++; twenties++; tens++; }
  51. if (calc == 9) { fifties++; twenties += 2; ; }
  52. //------------------------------------------------
  53. }
  54. if (Decimal_Final.Length == 2)
  55. {
  56.  
  57. calc = Convert.ToInt32(Convert.ToString(Decimal_Final[1])); // get the secodn part of the decimal
  58. // Console.WriteLine(calc);
  59. //------------------------------------------------
  60. if (calc == 1) { ones++; }
  61. if (calc == 2) { twos++; }
  62. if (calc == 3) { twos++; ones++; }
  63. if (calc == 4) { twos += 2; }
  64. if (calc == 5) { fives++; }
  65. if (calc == 6) { fives++; ones++; }
  66. if (calc == 7) { fives++; twos++; }
  67. if (calc == 8) { fives++; twos++; ones++; }
  68. if (calc == 9) { fives++; twos += 2; }
  69. //------------------------------------------------
  70. }
  71.  
  72.  
  73. if ((int)change == 1) { hundreds = 1; };
  74.  
  75. if ((int)change == 2)
  76. {
  77. hundreds = 1;
  78.  
  79.  
  80.  
  81. };
  82. if ((int)change > 2)
  83. {
  84. if ((int)change % 2 == 0)
  85. { hundreds = (int)change / 2; }
  86. else
  87. { hundreds = ((int)change / 2) + 1; }
  88. }
  89. //-------------------------------------
  90.  
  91.  
  92. Console.WriteLine(hundreds + tens + twenties + fifties + twos + ones + fives);
  93.  
  94.  
  95. }
  96. }
  97. }
  98.  
  99.  
  100.  
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement