Advertisement
RedFlys

HomeWork CLight BuyCrystal

May 24th, 2020
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BuyCrystal
  4. {
  5.     public class Test
  6.     {
  7.         public static void Main()
  8.         {
  9.             int money;
  10.             int priceCrystal = 10;
  11.             int maxBuyCrystal;
  12.             int wantBuyCrystal;
  13.            
  14.             Console.WriteLine($"Приветствую.Вы можете купить кристалы по цене {priceCrystal} монет. Сколько у вас монет? ");
  15.             money = Convert.ToInt32(Console.ReadLine());
  16.            
  17.             maxBuyCrystal = money / priceCrystal;
  18.            
  19.             Console.WriteLine($"Вы можете купить {maxBuyCrystal} кристаллов. Сколько хотите купить?");
  20.             wantBuyCrystal = Convert.ToInt32(Console.ReadLine());
  21.            
  22.             if(wantBuyCrystal <= maxBuyCrystal)
  23.             {
  24.                 money -= priceCrystal * wantBuyCrystal;
  25.                 Console.WriteLine($"Вы купили {wantBuyCrystal} кристаллов и у вас осталось {money} монет" );
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine("Вам не хватает монет");
  30.             }
  31.            
  32.             Console.ReadKey();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement