Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Trip_Expenses
- {
- class Program
- {
- static void Main(string[] args)
- {
- int countOfDaysOff = int.Parse(Console.ReadLine());
- int limitPerDay = 60;
- string command = string.Empty;
- int counterProduct = 0;
- int moneyLeft = 0;
- int sumSpend = 0;
- bool hasSpend = false;
- bool hasDayOff = false;
- for (int i = 1; i <= countOfDaysOff; i++)
- {
- while (true)
- {
- command = Console.ReadLine();
- counterProduct++;
- if (command != "Day over")
- {
- if (int.Parse(command) >= limitPerDay)
- {
- counterProduct = 0;
- continue;
- }
- else
- {
- sumSpend += int.Parse(command);
- if (sumSpend >= limitPerDay)
- {
- hasSpend = true;
- break;
- }
- //else
- //{
- // moneyLeft = limitPerDay - sumSpend;
- //}
- }
- }
- else if (command == "Day over") //|| (limitPerDay > sumSpend))
- {
- // limitPerDay += moneyLeft;
- counterProduct -= 1;
- hasDayOff = true;
- break;
- }
- }
- if (hasSpend == true)
- {
- Console.WriteLine($"Daily limit exceeded! You've bought {counterProduct} products.");
- //counterProduct = 0;
- //sumSpend = 0;
- }
- else if (hasDayOff == true)
- {
- moneyLeft = limitPerDay - sumSpend;
- Console.WriteLine($"Money left from today: {moneyLeft}. You've bought {counterProduct} products.");
- }
- counterProduct = 0;
- sumSpend = 0;
- //moneyLeft = limitPerDay - sumSpend;
- //limitPerDay += moneyLeft;
- counterProduct = 0;
- }
- moneyLeft = limitPerDay - sumSpend;
- limitPerDay += moneyLeft;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement