Advertisement
andy_brtn

Untitled

Mar 29th, 2020
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04.FoodForPets
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int days = int.Parse(Console.ReadLine());
  10. double food = int.Parse(Console.ReadLine());
  11.  
  12. double cookie = 0;
  13. int sumAllFoodEaten = 0;
  14. int sumcatFood = 0;
  15. int sumdogFood = 0;
  16. for (int day = 1; day <= days; day++)
  17. {
  18. int dogFood = int.Parse(Console.ReadLine());
  19. int catFood = int.Parse(Console.ReadLine());
  20.  
  21. if (day % 3 == 0)
  22. {
  23. int sum = dogFood + catFood;
  24. double percentageCookie = sum * 0.1;
  25. cookie = percentageCookie;
  26. }
  27. sumcatFood += catFood;
  28. sumdogFood += dogFood;
  29. sumAllFoodEaten = sumcatFood + sumdogFood;
  30.  
  31. }
  32. double percentageAllFood = (sumAllFoodEaten / food) * 100;
  33. double percentageDogFood = (sumdogFood * 1.0 / sumAllFoodEaten) * 100;
  34. double percentageCatFood = (sumcatFood * 1.0 / sumAllFoodEaten) * 100;
  35. Console.WriteLine($"Total eaten biscuits: {Math.Round(cookie)}gr.");
  36. Console.WriteLine($"{percentageAllFood:f2}% of the food has been eaten.");
  37. Console.WriteLine($"{percentageDogFood:f2}% eaten from the dog.");
  38. Console.WriteLine($"{percentageCatFood:f2}% eaten from the cat.");
  39.  
  40.  
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement