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