Torgach

Магазин

Apr 6th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Homework_1._2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             uint gold, crystalsCount;
  14.             uint crystalCost = 100 ;
  15.             bool enoughGold;
  16.  
  17.             Console.WriteLine("Вы приходите в магазин и хотите купить за своё золото кристаллы...");
  18.  
  19.             Console.Write("Введите начальное количество золота: ");
  20.             gold = Convert.ToUInt32(Console.ReadLine());
  21.             Console.WriteLine("Кристаллы продаются по цене " + crystalCost);
  22.  
  23.             Console.WriteLine("Сколько кристаллов нужно приобрести: ");
  24.             crystalsCount = Convert.ToUInt32(Console.ReadLine());
  25.  
  26.             enoughGold = gold >= crystalCost * crystalsCount;
  27.  
  28.             crystalsCount *= Convert.ToUInt32(enoughGold);
  29.             gold -= crystalsCount * crystalCost;
  30.  
  31.             Console.WriteLine("У вас в сумке: " + crystalsCount + " кристалла и " + gold + " золота.");
  32.  
  33.         }
  34.     }
  35. }
Add Comment
Please, Sign In to add comment