Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace IJunior1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int cristalPrice = 10;
  10.             int playerGold;
  11.  
  12.             Console.Write("Введите сколько золота у вас есть: ");
  13.             playerGold = Convert.ToInt32(Console.ReadLine());
  14.  
  15.             Console.Write("Сколько кристалов ты хочешь купить братишка: ");
  16.             int cristalsToBayCount = Convert.ToInt32(Console.ReadLine());
  17.  
  18.             bool isEnoughMoney = playerGold >= cristalsToBayCount * cristalPrice;
  19.             cristalsToBayCount *= Convert.ToInt32(isEnoughMoney);
  20.             playerGold -= cristalsToBayCount * cristalPrice;
  21.  
  22.             Console.WriteLine($"Вы купили {cristalsToBayCount} кристалов! У Вас осталось {playerGold} золота");
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement