Advertisement
desislava_topuzakova

04. Food for Pets

Mar 31st, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04._Food_for_Pets
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double availableFood = double.Parse(Console.ReadLine());
  11.  
  12.             double totalDog = 0;
  13.             double totalCat = 0;
  14.             double total = 0;
  15.             double totalBiscuits = 0;
  16.  
  17.             for (int day = 1; day <= days; day++)
  18.             {
  19.                 int dog = int.Parse(Console.ReadLine());
  20.                 int cat = int.Parse(Console.ReadLine());
  21.  
  22.                 totalDog += dog;
  23.                 totalCat += cat;
  24.                 total += dog + cat;
  25.  
  26.                 if (day % 3 == 0)
  27.                 {
  28.                     totalBiscuits += 0.10 * (dog + cat);
  29.                 }
  30.             }
  31.  
  32.             Console.WriteLine($"Total eaten biscuits: {Math.Round(totalBiscuits)}gr.");
  33.             double percentEaten = total / availableFood * 100;
  34.             Console.WriteLine($"{percentEaten:f2}% of the food has been eaten.");
  35.             double percentByDog = totalDog / total * 100;
  36.             Console.WriteLine($"{percentByDog:f2}% eaten from the dog.");
  37.             double percentByCat = totalCat / total * 100;
  38.             Console.WriteLine($"{percentByCat:f2}% eaten from the cat.");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement