Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active May 16, 2023 15:44
Show Gist options
  • Save Strelok78/168e5a3bff660eb9ce238ee081729d23 to your computer and use it in GitHub Desktop.
Save Strelok78/168e5a3bff660eb9ce238ee081729d23 to your computer and use it in GitHub Desktop.
At the start of the program, the user enters the initial amount of gold. Then he is offered to buy a certain number of crystals at the price of N. The user enter a number and his gold is converted into crystals. The rest of the gold and crystals are displayed on the screen.
namespace MyCode
{
internal class Program
{
static void Main(string[] args)
{
int gold;
int crystals;
int crystalPrice = 5;
Console.WriteLine("Enter your amount of gold");
gold = int.Parse(Console.ReadLine());
Console.WriteLine($"Price for each crystal is {crystalPrice}. How much do You want to buy?");
crystals = int.Parse(Console.ReadLine());
gold -= crystalPrice * crystals;
Console.WriteLine($"Curreently you have {gold} of gold and {crystals} of crystals");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment