Advertisement
mecies

NOTE/COIN COUNTER

Jun 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. function_kaska();
  4.  
  5.  
  6. }
  7. static void function_kaska()
  8. {
  9. Console.WriteLine("Enter the amount of money to be devided into coins and notes");
  10. double[] coins_notes = { 100, 50, 20, 10, 5, 2, 1 };
  11. double given_amount;
  12. if (!double.TryParse(Console.ReadLine(), out given_amount))
  13. {
  14. Console.WriteLine("give me some real amount bro (any key to exit)");
  15. Console.ReadKey();
  16. Environment.Exit(0);
  17. }
  18. Console.WriteLine("Number of nominals: ");
  19. int i = 0;
  20. while (given_amount > 0)
  21. {
  22. if (given_amount >= coins_notes[i])
  23. {
  24. int amount_of_coins_nominals = (int)(given_amount / coins_notes[i]);
  25. given_amount = Math.Round(given_amount - coins_notes[i] * amount_of_coins_nominals, 2); //Odjęcie wypłaconych środków od reszty
  26.  
  27. Console.WriteLine(amount_of_coins_nominals + " x " + "$" + coins_notes[i]);
  28. }
  29. i++;
  30. }
  31. Console.ReadKey();
  32.  
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement