Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp8
- {
- class Program
- {
- static void Main(string[] args)
- {
- int recommendedDoze = int.Parse(Console.ReadLine());
- int activitiesCnt = int.Parse(Console.ReadLine());
- int caloriesOff = 0;
- int sum = 0;
- for (int i = 0; i < activitiesCnt; i++)
- {
- string text = Console.ReadLine();
- int calories = int.Parse(Console.ReadLine());
- if (text == "eat")
- {
- sum += calories;
- }
- else if (text == "training")
- {
- sum -= calories;
- }
- if (recommendedDoze <= sum)
- {
- break;
- }
- }
- if (recommendedDoze >= sum)
- {
- Console.WriteLine("Nice job! Today was a heathy day!");
- Console.WriteLine($"Calories to the limit: {recommendedDoze - sum}");
- }
- else
- {
- Console.WriteLine("Oh no, it seems you ate too much...");
- Console.WriteLine($"Overdose: {sum - recommendedDoze}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement