Advertisement
Legiomax

C#_1_lesson_crystall's_shop

Jan 2nd, 2024 (edited)
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | Software | 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 C_Ijun
  8. {
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int money;
  14.             int crystallCount;
  15.             int crystallPrice;
  16.             bool enoughMoney;
  17.             Console.Write("Введите стоимость кристаллов: ");
  18.             crystallPrice = Convert.ToInt32(Console.ReadLine());
  19.             Console.WriteLine("Добро пожаловать в магазин кристаллов! Сегодня кристаллы по " + crystallPrice + " монет.");
  20.             Console.Write("Сколько у вас золота: ");
  21.             money = Convert.ToInt32(Console.ReadLine());
  22.             Console.Write("Сколько кристаллов вам нужно: ");
  23.             crystallCount = Convert.ToInt32(Console.ReadLine());
  24.  
  25.             enoughMoney = money >= crystallCount * crystallPrice;
  26.             crystallCount *= Convert.ToInt32(enoughMoney);
  27.             money -= crystallCount * crystallPrice;
  28.             Console.WriteLine("У вас в сумке - " + crystallCount + " кристаллов и " + money + " монет.");
  29.             Console.ReadLine();
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement