-
-
Save codecademydev/bfdd961d7689407eb6b2ef62cf7ee7f6 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 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