Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.Tourist_Shop
- {
- class Program
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- int numberOfProducts = 0;
- double sum = 0;
- while (true)
- {
- string productName = Console.ReadLine();
- if (productName == "Stop")
- {
- Console.WriteLine($"You bought {numberOfProducts} products for {sum:f2} leva.");
- break;
- }
- else
- {
- numberOfProducts++;
- double productPrice = double.Parse(Console.ReadLine());
- if (productPrice > budget)
- {
- Console.WriteLine($"You don't have enough money!");
- Console.WriteLine($"You need {productPrice - budget:f2} leva!");
- break;
- }
- if (numberOfProducts % 3 == 0)
- {
- sum += productPrice / 2;
- budget -= productPrice / 2;
- }
- else
- {
- sum += productPrice;
- budget -= productPrice;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement