Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 4, 2021 19:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/1ae64242e67e0e10f4806e80e4700e1e to your computer and use it in GitHub Desktop.
Save codecademydev/1ae64242e67e0e10f4806e80e4700e1e to your computer and use it in GitHub Desktop.
Codecademy export
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