Pirnogion

IJCSHW6

Sep 21st, 2025
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace CSLite1
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Console.InputEncoding = Encoding.Unicode;
  11.             Console.OutputEncoding = Encoding.Unicode;
  12.  
  13.             int crystalPrice = 19;
  14.  
  15.             int goldCount;
  16.             int crystalsCount = 0;
  17.  
  18.             Console.Write("Сколько у вас золотых: ");
  19.             goldCount = Convert.ToInt32(Console.ReadLine());
  20.  
  21.             int requestedCrystalsCount;
  22.             Console.Write($"Сколько кристаллов вы желаете приобрести (цена за кристалл {crystalPrice} золотых): ");
  23.             requestedCrystalsCount = Convert.ToInt32(Console.ReadLine());
  24.  
  25.             int dealPrice = requestedCrystalsCount * crystalPrice;
  26.             Console.WriteLine($"Вы получите {requestedCrystalsCount} кристаллов затратив {dealPrice} золотых.");
  27.  
  28.             goldCount -= dealPrice;
  29.             crystalsCount += requestedCrystalsCount;
  30.  
  31.             Console.WriteLine($"Количество золота: {goldCount}, количество кристаллов: {crystalsCount}.");
  32.             Console.ReadKey();
  33.         }
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment