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 ConsoleApplication25
- {
- class Program
- {
- static void Main(string[] args)
- {//prochitame broq dni pochivka na desi
- int days = int.Parse(Console.ReadLine());
- double budget = 0.0;
- //vurtim cikul kolkoto dni imame
- for (int i = 0; i < days; i++)
- {
- budget += 60;
- int products = 0;
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "Day over")
- {
- Console.WriteLine("Money left from today: {0}. You've bought {1} products.", budget.ToString("0.00"), products);
- //prikluchvame denq
- break;
- }
- double productPrice = double.Parse(command);
- if (budget - productPrice < 0)
- {
- Console.WriteLine("Daily limit exceeded!You've bought {0} products.", products);
- //krai kogato nqma pari
- break;
- }
- else if (budget - productPrice == 0)
- {
- products += 1;
- Console.WriteLine("Daily limit exceeded!You've bought {0} products.", products);
- //krai kogato nqma pari
- break;
- }
- else
- {
- //parite dostigatm, premahvame ot budgeta i dobavqne na tavana u koshnicata
- budget -= productPrice;
- products += 1;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement