-
-
Save codecademydev/1ae64242e67e0e10f4806e80e4700e1e to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace MoneyMaker | |
{ | |
class MainClass | |
{ | |
public static void Main(string[] args) | |
{ | |
Console.WriteLine("Welcome to Money Maker!"); | |
Console.WriteLine("Enter an amount to convert to coins?"); | |
string money = Console.ReadLine(); | |
double moneyi = Convert.ToDouble(money); | |
// let the user know howmuch he insert | |
Console.WriteLine($"{moneyi} is equal to..."); | |
// convert to coins. | |
double gold = 10; | |
double silver = 5; | |
//checking howmany gold coins fit | |
double goldCoins = Math.Round(moneyi / gold); | |
//checks howmuch is left from the total money. | |
double remainder = moneyi % gold; | |
//Checking howmany silver coins fit in the left overs | |
double silverCoins = Math.Round(remainder / silver); | |
remainder = remainder % silver; | |
//Print everything to the console | |
Console.WriteLine($"Gold Coins = {goldCoins}"); | |
Console.WriteLine($"Silver Coins = {silverCoins}"); | |
Console.WriteLine($"Bronze Coins = {remainder}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment