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