Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04.TouristShop
- {
- class TouristShop
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- string nameProduct = Console.ReadLine();
- int countEquipment = 1;
- double sumCost = 0;
- while (nameProduct != "Stop")
- {
- double price = double.Parse(Console.ReadLine());
- if (countEquipment % 3 == 0)
- {
- price /= 2;
- }
- if (price > budget)
- {
- double needed = price - budget;
- Console.WriteLine($"You don't have enough money!");
- Console.WriteLine($"You need {needed:f2} leva!");
- break;
- }
- countEquipment++;
- budget -= price;
- sumCost += price;
- nameProduct = Console.ReadLine();
- }
- if (nameProduct == "Stop")
- {
- double fix = countEquipment - 1;
- Console.WriteLine($"You bought {fix} products for {sumCost:f2} leva.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement