Advertisement
RedFlys

Home Work 1.6 (extra)

Oct 23rd, 2019
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 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 ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int money;
  14.             int costOfCrystal = 30;
  15.             int canBuyCrystal;
  16.             int crystal;
  17.  
  18.             Console.WriteLine($"Приветствуем вас в нашем магазине кристаллов. Вы можете купить 1 кристалл за {costOfCrystal} монет. Вы пересчитываете монеты своём кошельке. У вас:");
  19.             money = Convert.ToInt32(Console.ReadLine());
  20.             Console.WriteLine($"У вас целых {money} монет.");
  21.  
  22.             canBuyCrystal = money / costOfCrystal;
  23.  
  24.             Console.WriteLine($"Вы можете купить {canBuyCrystal} кристаллов. Сколько хотите купить?");
  25.             int wantBuyCrystal = Convert.ToInt32(Console.ReadLine());
  26.  
  27.             bool buy = canBuyCrystal >= wantBuyCrystal;
  28.             crystal = Convert.ToInt32(buy) * wantBuyCrystal;
  29.             money -=(Convert.ToInt32(buy) * wantBuyCrystal * costOfCrystal);
  30.  
  31.             string buyCrystal = $"У вас {crystal} кристаллов и {money} монет.";
  32.  
  33.             Console.WriteLine(buyCrystal);
  34.             Console.ReadKey();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement