Advertisement
MustyElbow

CrystalStore

Aug 26th, 2023 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Policy;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace CrystalStore
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int gold;
  15.             int crystals;        
  16.             int priceCrystal = 15;
  17.             int totalCrystalsInStore = 30;
  18.             bool isAbleToBuy;
  19.             bool isAbleToSell;
  20.  
  21.             Console.WriteLine("Сколько у вас золота?");
  22.             gold = Convert.ToInt32(Console.ReadLine());
  23.             Console.WriteLine($"В нашем магазине есть {totalCrystalsInStore} кристаллов. Сколько кристаллов Вы хотите приобрести?");
  24.             crystals = Convert.ToInt32(Console.ReadLine());
  25.  
  26.             isAbleToBuy = gold >= crystals * priceCrystal;
  27.             crystals *= Convert.ToInt32(isAbleToBuy);
  28.             isAbleToSell = totalCrystalsInStore >= crystals;
  29.             crystals *= Convert.ToInt32(isAbleToSell);
  30.             totalCrystalsInStore -= crystals;
  31.             gold -= (crystals * priceCrystal);
  32.  
  33.             Console.WriteLine($"Вы приобрели {crystals} кристаллов. У вас осталось {gold} золота. В магазине осталось {totalCrystalsInStore} кристаллов");
  34.  
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement