Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04._Tourist_Shop
- {
- class Program
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- string product = Console.ReadLine();
- int counterProduct = 0;
- int counterDiscount = 0;
- bool noMoney = false;
- double price = 0;
- while (product != "Stop")
- {
- double priceProduct = double.Parse(Console.ReadLine());
- counterProduct++;
- counterDiscount++;
- if (counterDiscount == 3)
- {
- priceProduct /= 2;
- counterDiscount = 0;
- }
- price += priceProduct;
- if (price > budget)
- {
- Console.WriteLine($"You don't have enough money!");
- Console.WriteLine($"You need {Math.Abs(price - budget):f2} leva!");
- noMoney = true;
- break;
- }
- product = Console.ReadLine();
- }
- if (!noMoney)
- {
- Console.WriteLine($"You bought {counterProduct} products for {price:f2} leva.") ;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement