using System; /* Name: Random Coin Generator V1.0a * Description: This program creates a random number of coins, then adds the total. Wrote this program from scratch, no help from anyone. * Inspired by a machine I saw in real life (long story) * Author: Ken (captain-obvious) * Warning: If you steal this *simple* program, you're just lame and your lack of programming ability is made obvious. */ namespace Random_Coin_Generator_CLI { class Program { static void Main(string[] args) { Console.WriteLine("Press 1 then enter to start the program, or 2 then enter to exit the program."); while (true) { int reply = Console.Read(); //ASCII value of 1 is 49, ASCII value of 2 is 50, etc, too lazy to convert from an ASCII value since it's not necessary. if (reply == 49) { int dollars = 0; int cents = 0; string total = ""; Console.WriteLine(); string[] coinTypes = new string[] {"Toonie", "Loonie", "Quarter", "Dime", "Nickel", "Penny"}; int[] numberOfCoins = new int[6]; var r = new Random(); Console.WriteLine("Coin Type Number of Type"); for (int x = 0; x < coinTypes.Length; x++) { int randomNumber = r.Next(100); numberOfCoins[x] += randomNumber; Console.WriteLine(coinTypes[x] + " \t " + numberOfCoins[x]); switch(coinTypes[x]) { case "Toonie": dollars += 2 * numberOfCoins[x]; break; case "Loonie": dollars += 1 * numberOfCoins[x]; break; case "Quarter": cents += 25 * numberOfCoins[x]; break; case "Dime": cents += 10 * numberOfCoins[x]; break; case "Nickel": cents += 5 * numberOfCoins[x]; break; case "Penny": cents += 1 * numberOfCoins[x]; break; } } if (cents > 60) { dollars += (cents/60); cents -= ((cents/60)*60); } total = Convert.ToString(dollars + " dollars " + cents + " cents."); Console.WriteLine("The total amount of money is: " + total); Console.WriteLine("Press 1 then enter again to continue the program, otherwise press 2 then enter to exit the program..."); reply = Console.Read(); } else if (reply == 50) { Environment.Exit(0); } } } } }