Advertisement
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 CSLight_HW_4
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.OutputEncoding = Encoding.UTF8;
- int goldAmount;
- int diamondAmount;
- int diamondPrice = 10;
- bool enoughGold;
- Console.WriteLine($"ЗДравствуйте! Сегодня у нас алмазы по {diamondPrice} золота");
- Console.Write("Сколько у вас золота: ");
- goldAmount = Convert.ToInt32(Console.ReadLine());
- Console.Write("Сколько кристаллов вы хотите купить: ");
- diamondAmount = Convert.ToInt32(Console.ReadLine());
- enoughGold = goldAmount >= diamondAmount * diamondPrice;
- diamondAmount *= Convert.ToInt32(enoughGold);
- goldAmount -= diamondAmount * diamondPrice;
- Console.Write($"Вы купили {diamondAmount} кристалов и у вас осталось {goldAmount} золота");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement