ranee

Untitled

Jun 13th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Dynamic;
  4. using System.Linq;
  5. using System.Runtime.Serialization;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace CSLight
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.  
  16.             int gold;
  17.             int crystalPrice = 3;
  18.             int crystalCount;
  19.             bool enoughGold;
  20.             Console.WriteLine($"Кристаллы по {crystalPrice} монеты");
  21.             Console.Write($"Сколько у вас золота:");
  22.             gold = Convert.ToInt32(Console.ReadLine());
  23.             Console.Write("Сколько кристаллов нужно:");
  24.             crystalCount = Convert.ToInt32(Console.ReadLine());
  25.            
  26.            
  27.             enoughGold = gold >= crystalCount * crystalPrice;
  28.            
  29.             crystalCount *= Convert.ToInt32(enoughGold);
  30.             gold -= crystalCount * crystalPrice;
  31.             Console.WriteLine($"У вас {crystalCount} кристаллов и {gold} монет.");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment