Advertisement
Ang377ou

changecount

Mar 23rd, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace activity4
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. decimal amt = 0;
  13. Console.Write("Enter Amt:");
  14. amt = decimal.Parse(Console.ReadLine());
  15.  
  16. Console.WriteLine(Change(amt));
  17. }
  18. private static string Change(decimal n)
  19. {
  20. decimal[] C = {10,5,1,0.25m,0.10m,0.05m};
  21. string Sol= " ";
  22. decimal Sum = 0;
  23.  
  24.  
  25. while (Sum !=n)
  26. {
  27. for (int index = 0; index <= C.Length-1; )
  28. {
  29. if (Sum + C[index] <= n)
  30. {
  31. decimal x = C[index];
  32. Sol = Sol +" "+ x;
  33. Sum = Sum + x;
  34. }
  35. else
  36. index++;
  37. }
  38. }
  39. return Sol;
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement