Advertisement
Fox_McCloud77

CSLight_HW_4

Feb 11th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 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 CSLight_HW_4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.OutputEncoding = Encoding.UTF8;
  14.  
  15.             int goldAmount;
  16.             int diamondAmount;
  17.             int diamondPrice = 10;
  18.             bool enoughGold;
  19.  
  20.             Console.WriteLine($"ЗДравствуйте! Сегодня у нас алмазы по {diamondPrice} золота");
  21.             Console.Write("Сколько у вас золота: ");
  22.             goldAmount = Convert.ToInt32(Console.ReadLine());
  23.             Console.Write("Сколько кристаллов вы хотите купить: ");
  24.             diamondAmount = Convert.ToInt32(Console.ReadLine());
  25.  
  26.             enoughGold = goldAmount >= diamondAmount * diamondPrice;
  27.  
  28.             diamondAmount *= Convert.ToInt32(enoughGold);
  29.             goldAmount -= diamondAmount * diamondPrice;
  30.  
  31.             Console.Write($"Вы купили {diamondAmount} кристалов и у вас осталось {goldAmount} золота");
  32.             Console.ReadKey();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement