KpucTaJl

Магазин кристаллов

Aug 28th, 2023
971
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSLight
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int costCrystal = 7;
  10.             Console.WriteLine($"Цена одного кристалла равна {costCrystal}");
  11.  
  12.             Console.Write("Введите ваше кол-во золота: ");
  13.             int amountGold = Convert.ToInt32(Console.ReadLine());
  14.  
  15.             Console.Write("Введите кол-во кристаллов, которое вы хотите купить: ");
  16.             int amountCrystal = Convert.ToInt32(Console.ReadLine());
  17.  
  18.             int amountRequired = amountCrystal * costCrystal;
  19.  
  20.             if (amountRequired > amountGold)
  21.             {
  22.                 int amountMissing = amountRequired - amountGold;
  23.                 Console.WriteLine($"Вы не можете купить данное кол-во кристаллов ({amountCrystal} шт.), вам не хватает {amountMissing} золота");
  24.             }
  25.             else
  26.             {
  27.                 amountGold -= amountRequired;
  28.                 Console.WriteLine($"Вы купили кристаллы в количестве {amountCrystal} шт., у вас осталось {amountGold} золота");
  29.             }
  30.  
  31.             Console.ReadKey();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment