Advertisement
RedFlys

Home Work 1.6

Oct 23rd, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 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 cost_of_crystal = 30;
  15.             int crystal;
  16.             int balance_money;
  17.             int balance_crystal;
  18.  
  19.             Console.WriteLine($"Приветствуем вас в нашем магазине кристаллов. Вы можете купить 1 кристалл за {cost_of_crystal} монет. Вы пересчитываете монеты своём кошельке. У вас:");
  20.             money = Convert.ToInt32(Console.ReadLine());
  21.             Console.WriteLine($"У вас целых {money} монет.");
  22.  
  23.             crystal = money / cost_of_crystal;
  24.  
  25.             Console.WriteLine($"Вы можете купить {crystal} кристаллов. Сколько хотите купить?");
  26.             int want_buy_crystal = Convert.ToInt32(Console.ReadLine());
  27.  
  28.             balance_crystal = want_buy_crystal;
  29.             balance_money = money - (want_buy_crystal * cost_of_crystal);
  30.  
  31.             string buy_crystal = $"Вы купили кристаллы. Теперь у вас {balance_crystal} кристаллов и {balance_money} монет. Спасибо за покупку!";
  32.  
  33.             Console.WriteLine(buy_crystal);
  34.             Console.ReadKey();
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement