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