Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Policy;
- using System.Text;
- using System.Threading.Tasks;
- namespace CrystalStore
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int gold;
- int crystals;
- int priceCrystal = 15;
- int totalCrystalsInStore = 30;
- bool isAbleToBuy;
- bool isAbleToSell;
- Console.WriteLine("Сколько у вас золота?");
- gold = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine($"В нашем магазине есть {totalCrystalsInStore} кристаллов. Сколько кристаллов Вы хотите приобрести?");
- crystals = Convert.ToInt32(Console.ReadLine());
- isAbleToBuy = gold >= crystals * priceCrystal;
- crystals *= Convert.ToInt32(isAbleToBuy);
- isAbleToSell = totalCrystalsInStore >= crystals;
- crystals *= Convert.ToInt32(isAbleToSell);
- totalCrystalsInStore -= crystals;
- gold -= (crystals * priceCrystal);
- Console.WriteLine($"Вы приобрели {crystals} кристаллов. У вас осталось {gold} золота. В магазине осталось {totalCrystalsInStore} кристаллов");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement