Anzzhhela98

dd

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