Advertisement
silvana1303

food for pets

May 2nd, 2020
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double wholeFood = double.Parse(Console.ReadLine());
  11.             int dogSum = 0;
  12.             int catSum = 0;
  13.             int twoSum = 0;
  14.             double biscuits = 0.0;
  15.  
  16.             for (int i = 1; i <= days; i++)
  17.             {
  18.                 int dogFood = int.Parse(Console.ReadLine());
  19.                 int catFood = int.Parse(Console.ReadLine());
  20.  
  21.                 dogSum += dogFood;
  22.                 catSum += catFood;
  23.  
  24.                 twoSum += dogFood + catFood;
  25.  
  26.                 if (i % 3 == 0)
  27.                 {
  28.                     biscuits += (dogFood + catFood) * 0.10;
  29.                 }
  30.             }
  31.  
  32.             double percentFullFood = twoSum * 1.0 / wholeFood * 100.0;
  33.             double percentDogFood = dogSum * 1.0 / twoSum * 100.0;
  34.             double percentCatFood = catSum * 1.0 / twoSum * 100.0;
  35.  
  36.             Console.WriteLine($"Total eaten biscuits: {Math.Floor(biscuits)}gr.");
  37.             Console.WriteLine($"{percentFullFood:f2}% of the food has been eaten.");
  38.             Console.WriteLine($"{percentDogFood:F2}% eaten from the dog.");
  39.             Console.WriteLine($"{percentCatFood:F2}% eaten from the cat.");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement