Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _04.FoodForPets
- {
- class Program
- {
- static void Main(string[] args)
- {
- int days = int.Parse(Console.ReadLine());
- double food = int.Parse(Console.ReadLine());
- double cookie = 0;
- int sumAllFoodEaten = 0;
- int sumcatFood = 0;
- int sumdogFood = 0;
- for (int day = 1; day <= days; day++)
- {
- int dogFood = int.Parse(Console.ReadLine());
- int catFood = int.Parse(Console.ReadLine());
- if (day % 3 == 0)
- {
- int sum = dogFood + catFood;
- double percentageCookie = sum * 0.1;
- cookie = percentageCookie;
- }
- sumcatFood += catFood;
- sumdogFood += dogFood;
- sumAllFoodEaten = sumcatFood + sumdogFood;
- }
- double percentageAllFood = (sumAllFoodEaten / food) * 100;
- double percentageDogFood = (sumdogFood * 1.0 / sumAllFoodEaten) * 100;
- double percentageCatFood = (sumcatFood * 1.0 / sumAllFoodEaten) * 100;
- Console.WriteLine($"Total eaten biscuits: {Math.Round(cookie)}gr.");
- Console.WriteLine($"{percentageAllFood:f2}% of the food has been eaten.");
- Console.WriteLine($"{percentageDogFood:f2}% eaten from the dog.");
- Console.WriteLine($"{percentageCatFood:f2}% eaten from the cat.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement