Instantly share code, notes, and snippets.

# AbdiElmi/gist:4654722 Created Jan 28, 2013

What would you like to do?
[01/28/13] Challenge #119 [Easy] Change Calculator
 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ChangeCalculator { class Program { static int quarter = 0; static int dime = 0; static int nickel = 0; static int penny = 0; static void Main(string[] args) { Console.Write("Enter Amount (\$): "); string input = Console.ReadLine(); decimal input_amount; bool result = Decimal.TryParse(input, out input_amount); Change(input_amount * 100); Console.WriteLine("Quarterers: " + quarter + "\nDimes: " + dime + "\nNickels: " + nickel + "\nPennies: " + penny); Console.ReadLine(); } //Recursive (i think) Change() method, accepting 1 argument(decimal amount) static void Change(decimal amount) { if (amount >= 25) { amount = amount - 25; quarter++; Change(amount); } else if (amount >= 10) { amount = amount - 10; dime++; Change(amount); } else if (amount >= 5) { amount = amount - 5; nickel++; Change(amount); } else if (amount >= 1) { amount = amount - 1; penny++; Change(amount); } } } }