W1thr

Домашка №4

Jan 7th, 2021 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 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 Homework9
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int goldCount;
  14.             int crystalCount;
  15.             int price = 5;
  16.             bool isEnough;
  17.  
  18.             Console.Write("Сколько у вас золота: ");
  19.             goldCount = Convert.ToInt32(Console.ReadLine());
  20.  
  21.             Console.Write("Сколько вы хотите купить алмазов: ");
  22.             crystalCount = Convert.ToInt32(Console.ReadLine());
  23.  
  24.             isEnough = goldCount >= crystalCount * price;
  25.             goldCount -= crystalCount * price * Convert.ToInt32(isEnough);
  26.             crystalCount *= Convert.ToInt32(isEnough);
  27.  
  28.             Console.WriteLine($"У вас осталось {goldCount} золота. Вы купили {crystalCount} кристаллов");
  29.         }
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment