Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Задание_4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int buyerGoldAmount;
- int costOfCrystal = 9;
- int numberOfDesiredCrystals;
- bool areThereEnoughmoney;
- Console.Write("Внимание! Введите начальное количество золота покупателя:");
- buyerGoldAmount = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine($"Количество золота покупателя установлено. У покупателя {buyerGoldAmount} золота");
- Console.WriteLine($"Здравствуй, путник. Один крисстал стоит {costOfCrystal} золота");
- Console.Write($"У вас сейчас {buyerGoldAmount} золота. Сколько кристаллов желаете приобрести? :");
- numberOfDesiredCrystals = Convert.ToInt32(Console.ReadLine());
- areThereEnoughmoney = buyerGoldAmount >= costOfCrystal * numberOfDesiredCrystals;
- numberOfDesiredCrystals *= Convert.ToInt32(areThereEnoughmoney);
- buyerGoldAmount -= costOfCrystal * numberOfDesiredCrystals;
- Console.WriteLine($"Вы купили {numberOfDesiredCrystals} кристаллов. У вас осталось {buyerGoldAmount} монет");
- }
- }
- }
Add Comment
Please, Sign In to add comment