Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace exampreparation
- {
- class exam
- {
- static void Main(string[] args)
- {
- int days = int.Parse(Console.ReadLine());
- double wholeFood = double.Parse(Console.ReadLine());
- int dogSum = 0;
- int catSum = 0;
- int twoSum = 0;
- double biscuits = 0.0;
- for (int i = 1; i <= days; i++)
- {
- int dogFood = int.Parse(Console.ReadLine());
- int catFood = int.Parse(Console.ReadLine());
- dogSum += dogFood;
- catSum += catFood;
- twoSum += dogFood + catFood;
- if (i % 3 == 0)
- {
- biscuits += (dogFood + catFood) * 0.10;
- }
- }
- double percentFullFood = twoSum * 1.0 / wholeFood * 100.0;
- double percentDogFood = dogSum * 1.0 / twoSum * 100.0;
- double percentCatFood = catSum * 1.0 / twoSum * 100.0;
- Console.WriteLine($"Total eaten biscuits: {Math.Floor(biscuits)}gr.");
- Console.WriteLine($"{percentFullFood:f2}% of the food has been eaten.");
- Console.WriteLine($"{percentDogFood:F2}% eaten from the dog.");
- Console.WriteLine($"{percentCatFood:F2}% eaten from the cat.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement