voldmaks

Магазин

Feb 20th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 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 Задание_4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int buyerGoldAmount;
  14.             int costOfCrystal = 9;
  15.             int numberOfDesiredCrystals;
  16.             bool areThereEnoughmoney;
  17.  
  18.             Console.Write("Внимание! Введите начальное количество золота покупателя:");
  19.             buyerGoldAmount = Convert.ToInt32(Console.ReadLine());
  20.             Console.WriteLine($"Количество золота покупателя установлено. У покупателя {buyerGoldAmount} золота");
  21.  
  22.             Console.WriteLine($"Здравствуй, путник. Один крисстал стоит {costOfCrystal} золота");
  23.             Console.Write($"У вас сейчас {buyerGoldAmount} золота. Сколько кристаллов желаете приобрести? :");
  24.             numberOfDesiredCrystals = Convert.ToInt32(Console.ReadLine());
  25.  
  26.             areThereEnoughmoney = buyerGoldAmount >= costOfCrystal * numberOfDesiredCrystals;
  27.            
  28.             numberOfDesiredCrystals *= Convert.ToInt32(areThereEnoughmoney);
  29.             buyerGoldAmount -= costOfCrystal * numberOfDesiredCrystals;
  30.  
  31.             Console.WriteLine($"Вы купили {numberOfDesiredCrystals} кристаллов. У вас осталось {buyerGoldAmount} монет");
  32.         }
  33.     }
  34. }
Add Comment
Please, Sign In to add comment