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 product = Console.ReadLine();
- double sum = 0;
- double counter = 0;
- while (product != "Stop")
- {
- double price = double.Parse(Console.ReadLine());
- counter++;
- if (counter % 3 == 0)
- {
- price /= 2;
- }
- sum += price;
- if (budget < sum)
- {
- break;
- }
- product = Console.ReadLine();
- }
- if (product == "Stop")
- {
- Console.WriteLine($"You bought {counter} products for {sum:F2} leva.");
- }
- else
- {
- Console.WriteLine("You don't have enough money!");
- Console.WriteLine($"You need {sum - budget:F2} leva!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment