mirea-projects/Third term/Programming of corporate systems/2/2.cs
2024-09-24 02:22:33 +03:00

36 lines
918 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
class ATMProgram
{
static void Main()
{
int[] banknotes = { 5000, 2000, 1000, 500, 200, 100 };
Console.Write("Введите сумму, которую хотите обналичить: ");
int amount = int.Parse(Console.ReadLine());
if (amount > 150000)
{
Console.WriteLine("Cумма должна быть меньше 150 000 рублей");
return;
}
if (amount % 100 != 0)
{
Console.WriteLine("Cумма должна быть кратна 100");
return;
}
Console.WriteLine("Купюры:");
foreach (int note in banknotes)
{
int count = amount / note;
if (count > 0)
{
Console.WriteLine($"{count} - {note} руб");
amount -= count * note;
}
}
}
}