Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 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 sumDogEats = 0;
  10. int sumCatEats = 0;
  11. double sumBisquits = 0;
  12.  
  13. int numDays = int.Parse(Console.ReadLine());
  14. double allFood = double.Parse(Console.ReadLine());
  15.  
  16. for (int countDays = 1; countDays <= numDays; countDays++)
  17. {
  18. int dogEatsDay = int.Parse(Console.ReadLine());
  19. int catEatsDay = int.Parse(Console.ReadLine());
  20. sumDogEats += dogEatsDay;
  21. sumCatEats += catEatsDay;
  22. if (countDays % 3 == 0)
  23. {
  24. sumBisquits += Math.Round((dogEatsDay + catEatsDay) * 0.1);
  25. }
  26. }
  27. int totalEatenFood = sumDogEats + sumCatEats;
  28. Console.WriteLine($"Total eaten biscuits: {sumBisquits}gr.");
  29. Console.WriteLine($"{1.0 * totalEatenFood / allFood * 100:F2}% of the food has been eaten.");
  30. Console.WriteLine($"{1.0 * sumDogEats / totalEatenFood * 100:F2}% eaten from the dog.");
  31. Console.WriteLine($"{1.0 * sumCatEats / totalEatenFood * 100:F2}% eaten from the cat.");
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement