Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace activity4
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal amt = 0;
- Console.Write("Enter Amt:");
- amt = decimal.Parse(Console.ReadLine());
- Console.WriteLine(Change(amt));
- }
- private static string Change(decimal n)
- {
- decimal[] C = {10,5,1,0.25m,0.10m,0.05m};
- string Sol= " ";
- decimal Sum = 0;
- while (Sum !=n)
- {
- for (int index = 0; index <= C.Length-1; )
- {
- if (Sum + C[index] <= n)
- {
- decimal x = C[index];
- Sol = Sol +" "+ x;
- Sum = Sum + x;
- }
- else
- index++;
- }
- }
- return Sol;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement