Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- function_kaska();
- }
- static void function_kaska()
- {
- Console.WriteLine("Enter the amount of money to be devided into coins and notes");
- double[] coins_notes = { 100, 50, 20, 10, 5, 2, 1 };
- double given_amount;
- if (!double.TryParse(Console.ReadLine(), out given_amount))
- {
- Console.WriteLine("give me some real amount bro (any key to exit)");
- Console.ReadKey();
- Environment.Exit(0);
- }
- Console.WriteLine("Number of nominals: ");
- int i = 0;
- while (given_amount > 0)
- {
- if (given_amount >= coins_notes[i])
- {
- int amount_of_coins_nominals = (int)(given_amount / coins_notes[i]);
- given_amount = Math.Round(given_amount - coins_notes[i] * amount_of_coins_nominals, 2); //Odjęcie wypłaconych środków od reszty
- Console.WriteLine(amount_of_coins_nominals + " x " + "$" + coins_notes[i]);
- }
- i++;
- }
- Console.ReadKey();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement