Advertisement
asvd32

04

Feb 1st, 2025
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp3
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int priceOfCrystal = 10;
  10.             int countOfCrystal;
  11.             int userGold;
  12.             int remainingGold;
  13.             bool isAbleToPay;
  14.  
  15.             Console.Write("Введите количество золота: ");
  16.             userGold = Convert.ToInt32(Console.ReadLine());
  17.             Console.Write($"Стоимость одного кримстала - {priceOfCrystal} золота. Сколько кристалов хотите купить?: ");
  18.             countOfCrystal = Convert.ToInt32(Console.ReadLine());
  19.  
  20.             isAbleToPay = userGold >= countOfCrystal * priceOfCrystal;
  21.             countOfCrystal = (countOfCrystal * Convert.ToInt32(isAbleToPay));
  22.             remainingGold = userGold - countOfCrystal * priceOfCrystal;
  23.  
  24.             Console.WriteLine($"Вы купили {countOfCrystal} кристалов. Ваш баланс - {remainingGold} золота.");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement