Advertisement
Anonim_999

Untitled

Nov 29th, 2020 (edited)
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 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 ConsoleApp5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int userGoldCount, userDimondCount;
  14.             int diamondPrice = 10;
  15.             Console.Write("Сколько у вас золота?: ");
  16.             userGoldCount = Convert.ToInt32(Console.ReadLine());
  17.             Console.Write($"1 кристалл стоит {diamondPrice} золота\n" +
  18.                 "Сколько кристаллов вы хотите купить?: ");
  19.             userDimondCount = Convert.ToInt32(Console.ReadLine());
  20.             int diamondPriceCount = userDimondCount * diamondPrice;
  21.             if (userGoldCount >= diamondPriceCount)
  22.             {
  23.                 userGoldCount -= diamondPriceCount;
  24.                 Console.WriteLine("Успешно!");
  25.             }
  26.             else
  27.             {
  28.                 userDimondCount = 0;
  29.                 Console.WriteLine("Недостаточно золота");
  30.             }
  31.             Console.WriteLine($"Кол-во Золота: {userGoldCount}\n" +
  32.                 $"Кол-во Кристаллов: {userDimondCount}");
  33.             Console.ReadKey();
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement