Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int goldCount;
- int crystalPrice = 10;
- int crystalCount;
- int crystalAllPrice;
- bool isBuying = false;
- Console.WriteLine("Сколько у вас золота в кошельке?");
- goldCount = Convert.ToInt32(Console.ReadLine());
- while (isBuying != true)
- {
- Console.Clear();
- Console.WriteLine($"У вас {goldCount} золота в кошельке.\nЦена 1 кристалла {crystalPrice} золота.\nСколько кристисталлов вы хотите купить?");
- crystalCount = Convert.ToInt32(Console.ReadLine());
- crystalAllPrice = crystalCount * crystalPrice;
- if (crystalAllPrice <= goldCount)
- {
- goldCount -= crystalAllPrice;
- isBuying = true;
- Console.WriteLine($"Вы купили {crystalCount} кристаллов.\nВ кошельке осталось {goldCount} золота.");
- }
- else if (crystalAllPrice >= goldCount)
- {
- Console.WriteLine("У вас недостаточно средств!\nПопробуйте еще раз.");
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement