Advertisement
Stan0033

Untitled

Apr 16th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 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.  
  22.  
  23.  
  24.  
  25.  
  26. // int decimal_part_int = (int)decimal_part;
  27. int calc;
  28. // string check = Convert.ToString(decimal_part_int);
  29.  
  30.  
  31.  
  32.  
  33.  
  34. if (Change_as_text.Length >= 3)
  35. {
  36.  
  37. //------------------------------------------------
  38.  
  39. calc = Convert.ToInt32(Convert.ToString(Change_as_text[2])); // get the first digit of the decimal
  40.  
  41. if (calc == 1) { tens++; }
  42. if (calc == 2) { twenties++; }
  43. if (calc == 3) { twenties++; tens++; }
  44. if (calc == 4) { twenties += 2; }
  45. if (calc == 5) { fifties++; }
  46. if (calc == 6) { fifties++; tens++; }
  47. if (calc == 7) { fifties++; twenties++; }
  48. if (calc == 8) { fifties++; twenties++; tens++; }
  49. if (calc == 9) { fifties++; twenties += 2; ; }
  50. //------------------------------------------------
  51. }
  52. if (Change_as_text.Length == 4)
  53. {
  54.  
  55. calc = Convert.ToInt32(Convert.ToString(Change_as_text[3])); // get the secodn part of the decimal
  56.  
  57. //------------------------------------------------
  58. if (calc == 1) { ones++; }
  59. if (calc == 2) { twos++; }
  60. if (calc == 3) { twos++; ones++; }
  61. if (calc == 4) { twos += 2; }
  62. if (calc == 5) { fives++; }
  63. if (calc == 6) { fives++; ones++; }
  64. if (calc == 7) { fives++; twos++; }
  65. if (calc == 8) { fives++; twos++; ones++; }
  66. if (calc == 9) { fives++; twos += 2; }
  67. //------------------------------------------------
  68. }
  69.  
  70.  
  71. if ((int)change == 1) { hundreds = 1; };
  72.  
  73. if ((int)change == 2) {
  74. hundreds = 1;
  75.  
  76.  
  77.  
  78. };
  79. if ((int)change > 2) {
  80. if ((int)change % 2 == 0)
  81. { hundreds = (int)change /2; }
  82. else
  83. { hundreds = ((int)change /2)+ 1; } }
  84. //-------------------------------------
  85.  
  86.  
  87. Console.WriteLine(hundreds + tens + twenties + fifties + twos + ones + fives);
  88.  
  89. }
  90. }
  91. }
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement