Advertisement
Rodunskiy

Untitled

Mar 31st, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. int goldCount = 100;
  2. int crystalPrice = 10;
  3. int crystalCount;
  4. bool enoughMoney;
  5.  
  6. Console.Write("Сколько кристаллов вы хотите купить?");
  7. crystalCount = Convert.ToInt32(Console.ReadLine());
  8.  
  9. enoughMoney = goldCount >= crystalCount * crystalPrice;
  10. crystalCount *= Convert.ToInt32(enoughMoney);
  11. goldCount -= crystalCount * crystalPrice;
  12.  
  13. Console.WriteLine($"После сделки у вас осталось {goldCount} золота и появилось {crystalCount} кристаллов.");
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement