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