Advertisement
didak1t

Untitled

Jan 4th, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | Source Code | 0 0
  1.  
  2.         double inputMoney = double.Parse(Console.ReadLine());
  3.  
  4.         int moneyInCoins = ((int)inputMoney * 100);
  5.        
  6.  
  7.        
  8.         int[] banknotes = { 10000, 5000, 2000, 1000, 500 };
  9.         int[] banknotesCount = new int[banknotes.Length];
  10.  
  11.         int[] coins = { 200, 100, 50, 25, 10, 5, 1 };
  12.         int[] coinsCount = new int[coins.Length];
  13.  
  14.         for (int i = 0; i < banknotes.Length; i++)
  15.         {
  16.             banknotesCount[i] = moneyInCoins / banknotes[i];
  17.             moneyInCoins %= banknotes[i];
  18.         }
  19.  
  20.         for (int i = 0; i < coins.Length; i++)
  21.         {
  22.             coinsCount[i] = moneyInCoins / coins[i];
  23.             moneyInCoins %= coins[i];
  24.         }
  25.  
  26.         Console.WriteLine($"БАНКНОТИ:");
  27.         for (int i = 0; i < banknotes.Length; i++)
  28.         {
  29.             Console.WriteLine($"{banknotesCount[i]} от {banknotes[i] / 100:f2}лв.");
  30.         }
  31.  
  32.         Console.WriteLine($"МОНЕТИ:");
  33.         for (int i = 0; i < coins.Length; i++)
  34.         {
  35.             if (coins[i] >= 100)
  36.             {
  37.                 Console.WriteLine($"{coinsCount[i]} от {coins[i] / 100:f2}лв.");
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine($"{coinsCount[i]} от {(double)coins[i] / 100:f2}лв.");
  42.             }
  43.            
  44.  
  45.         }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement