Advertisement
IzzoKisimoV

Food for Pets 100/100

May 18th, 2022
1,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 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.             int days = int.Parse(Console.ReadLine());
  10.             double food = double.Parse(Console.ReadLine());
  11.  
  12.             double dogFood = 0;
  13.             double catFood = 0;
  14.             double bisquits = 0;
  15.             double foodLeft = 0;
  16.             for (int i = 1; i <= days; i++)
  17.             {
  18.                 double dog = double.Parse(Console.ReadLine());
  19.                 double cat = double.Parse(Console.ReadLine());
  20.                 if (i % 3 == 0)
  21.                 {
  22.                     double currentBisquits = (dog + cat) * 0.10;
  23.                     bisquits += currentBisquits;
  24.                 }
  25.                 foodLeft = foodLeft + (dog + cat);
  26.                 dogFood = dogFood + dog;
  27.                 catFood = catFood + cat;
  28.             }
  29.             Console.WriteLine($"Total eaten biscuits: {Math.Round(bisquits)}gr.");
  30.             double totalEatenFood = foodLeft / food * 100;
  31.             Console.WriteLine($"{totalEatenFood:f2}% of the food has been eaten.");
  32.  
  33.             double foodEatenByDog = dogFood / foodLeft * 100;
  34.             Console.WriteLine($"{foodEatenByDog:f2}% eaten from the dog.");
  35.  
  36.             double foodEatenByCat = catFood / foodLeft * 100;
  37.             Console.WriteLine($"{foodEatenByCat:f2}% eaten from the cat.");
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement