Advertisement
Spocoman

Food for Pets

Nov 25th, 2021 (edited)
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace FoodForPets
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double food = double.Parse(Console.ReadLine());
  11.             int dogsFood = 0;
  12.             int catsFood = 0;
  13.             double cookies = 0;
  14.  
  15.             for (int i = 1; i <= days; i++)
  16.             {
  17.                 int dayFoodForDog = int.Parse(Console.ReadLine());
  18.                 int dayFoodForCat = int.Parse(Console.ReadLine());
  19.                 if (i % 3 == 0)
  20.                 {
  21.                     cookies += (double)(dayFoodForDog + dayFoodForCat) / 10;
  22.                 }
  23.                 dogsFood += dayFoodForDog;
  24.                 catsFood += dayFoodForCat;
  25.             }
  26.  
  27.             double totalFood = dogsFood + catsFood;
  28.             Console.WriteLine($"Total eaten biscuits: {Math.Round(cookies)}gr.");
  29.             Console.WriteLine($"{totalFood / food * 100:f2}% of the food has been eaten.");
  30.             Console.WriteLine($"{dogsFood / totalFood * 100:f2}% eaten from the dog.");
  31.             Console.WriteLine($"{catsFood / totalFood * 100:f2}% eaten from the cat.");
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement