Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double inputMoney = double.Parse(Console.ReadLine());
- int moneyInCoins = ((int)inputMoney * 100);
- int[] banknotes = { 10000, 5000, 2000, 1000, 500 };
- int[] banknotesCount = new int[banknotes.Length];
- int[] coins = { 200, 100, 50, 25, 10, 5, 1 };
- int[] coinsCount = new int[coins.Length];
- for (int i = 0; i < banknotes.Length; i++)
- {
- banknotesCount[i] = moneyInCoins / banknotes[i];
- moneyInCoins %= banknotes[i];
- }
- for (int i = 0; i < coins.Length; i++)
- {
- coinsCount[i] = moneyInCoins / coins[i];
- moneyInCoins %= coins[i];
- }
- Console.WriteLine($"БАНКНОТИ:");
- for (int i = 0; i < banknotes.Length; i++)
- {
- Console.WriteLine($"{banknotesCount[i]} от {banknotes[i] / 100:f2}лв.");
- }
- Console.WriteLine($"МОНЕТИ:");
- for (int i = 0; i < coins.Length; i++)
- {
- if (coins[i] >= 100)
- {
- Console.WriteLine($"{coinsCount[i]} от {coins[i] / 100:f2}лв.");
- }
- else
- {
- Console.WriteLine($"{coinsCount[i]} от {(double)coins[i] / 100:f2}лв.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement