Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created November 17, 2020 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/bfdd961d7689407eb6b2ef62cf7ee7f6 to your computer and use it in GitHub Desktop.
Save codecademydev/bfdd961d7689407eb6b2ef62cf7ee7f6 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 totalAsString = Console.ReadLine();
double totalAsDouble = Convert.ToDouble(totalAsString);
Console.WriteLine($"{totalAsDouble} cents is equal to...");
int gold = 10;
int silver = 5;
// calculating gold coins
double goldCoins = Math.Floor(totalAsDouble / gold);
double leftOver = totalAsDouble % gold;
double silverCoins = Math.Floor(leftOver / silver);
double remainder = leftOver % silver;
// printing all coins
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