Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TripExpenses
- {
- class Program
- {
- static void Main(string[] args)
- {
- int days = int.Parse(Console.ReadLine());
- string command;
- double dayCash = 0;
- for (int i = 0; i < days; i++)
- {
- int dayProducts = 0;
- dayCash += 60;
- while (true)
- {
- command = Console.ReadLine();
- if (command == "Day over")
- {
- Console.Write($"Money left from today: {dayCash:f2}.");
- break;
- }
- int productPrice = int.Parse(command);
- if (productPrice <= dayCash)
- {
- dayCash -= productPrice;
- dayProducts++;
- }
- if (dayCash == 0)
- {
- Console.Write("Daily limit exceeded!");
- break;
- }
- }
- Console.WriteLine($" You've bought {dayProducts} products.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement