Created
November 19, 2020 20:09
-
-
Save Hellhackee/8754702f9f490c435224d77e2b05a6ff to your computer and use it in GitHub Desktop.
CS Light Lesson 4.1(crystall's shop)
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
int goldCount; | |
int price = 12; | |
int crystallCount; | |
bool enoughGold; | |
Console.WriteLine("Доброго времени суток, путник, ты попал в лавку драгоценностей."); | |
Console.WriteLine($"Я готов предложить на продажу кристаллы по {price} золотых монет."); | |
Console.Write("Сколько золота у вас сейчас: "); | |
goldCount = Convert.ToInt32(Console.ReadLine()); | |
Console.Write("Сколько кристаллов ты хочешь купить: "); | |
crystallCount = Convert.ToInt32(Console.ReadLine()); | |
enoughGold = goldCount >= price * crystallCount; | |
crystallCount *= Convert.ToInt32(enoughGold); | |
goldCount -= crystallCount * price; | |
Console.WriteLine($"Сейчас у вас в кошельке {goldCount} золотых монет и {crystallCount} кристалла в рюкзаке."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment