Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CoinCounter
- {
- internal class Program
- {
- static readonly Tuple<string, int>[] Coins = new Tuple<string, int>[] {
- new Tuple<string, int>("Quarters", 25),
- new Tuple<string, int>("Dimes", 10) ,
- new Tuple<string, int>("Nichels", 5),
- new Tuple<string, int>("Pennies", 1) };
- static void Main(string[] args)
- {
- double amount;
- do
- {
- Console.WriteLine("Enter any positive currency amount: ");
- } while (!double.TryParse(Console.ReadLine(), out amount) || amount < 0);
- amount *= 100;
- for (int i = 0; i < 4; i++)
- {
- int quot = (int)(amount / Coins[i].Item2);
- amount -= quot * Coins[i].Item2;
- Console.WriteLine((Coins[i].Item1 + ":").PadRight(10) + quot);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment