Advertisement
Rodunskiy

Untitled

Apr 15th, 2024
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. int goldCount;
  2. int crystalPrice = 10;
  3. int crystalCount;
  4. int crystalAllPrice;
  5. bool isBuying = false;
  6.  
  7. Console.WriteLine("Сколько у вас золота в кошельке?");
  8. goldCount = Convert.ToInt32(Console.ReadLine());
  9.  
  10. while (isBuying != true)
  11. {
  12.     Console.Clear();
  13.     Console.WriteLine($"У вас {goldCount} золота в кошельке.\nЦена 1 кристалла {crystalPrice} золота.\nСколько кристисталлов вы хотите купить?");
  14.     crystalCount = Convert.ToInt32(Console.ReadLine());
  15.  
  16.     crystalAllPrice = crystalCount * crystalPrice;
  17.  
  18.     if (crystalAllPrice <= goldCount)
  19.     {
  20.         goldCount -= crystalAllPrice;
  21.         isBuying = true;
  22.  
  23.         Console.WriteLine($"Вы купили {crystalCount} кристаллов.\nВ кошельке осталось {goldCount} золота.");
  24.     }
  25.     else if (crystalAllPrice >= goldCount)
  26.     {
  27.         Console.WriteLine("У вас недостаточно средств!\nПопробуйте еще раз.");
  28.         Console.ReadLine();
  29.     }
  30. }
  31.  
  32.  
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement