Advertisement
Yanislav29

Untitled

Nov 30th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace ConsoleApp8
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int recommendedDoze = int.Parse(Console.ReadLine());
  11. int activitiesCnt = int.Parse(Console.ReadLine());
  12. int caloriesOff = 0;
  13. int sum = 0;
  14. for (int i = 0; i < activitiesCnt; i++)
  15. {
  16.  
  17. string text = Console.ReadLine();
  18. int calories = int.Parse(Console.ReadLine());
  19.  
  20. if (text == "eat")
  21. {
  22. sum += calories;
  23. }
  24. else if (text == "training")
  25. {
  26. sum -= calories;
  27. }
  28. if (recommendedDoze <= sum)
  29. {
  30.  
  31. break;
  32. }
  33.  
  34. }
  35. if (recommendedDoze >= sum)
  36. {
  37. Console.WriteLine("Nice job! Today was a heathy day!");
  38. Console.WriteLine($"Calories to the limit: {recommendedDoze - sum}");
  39. }
  40.  
  41. else
  42. {
  43. Console.WriteLine("Oh no, it seems you ate too much...");
  44. Console.WriteLine($"Overdose: {sum - recommendedDoze}");
  45. }
  46. }
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement