Advertisement
Guest User

05. PetFood

a guest
Dec 15th, 2019
100
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 _5ForLoop
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             double totalFood = double.Parse(Console.ReadLine());
  11.  
  12.             int eatenDogFood = 0;
  13.             int eatenCatFood = 0;
  14.             double eatenFood = 0;
  15.  
  16.             double buscuitPerday = 0;
  17.  
  18.             for (int dayCounter = 1; dayCounter <= days; dayCounter++)
  19.             {
  20.                 int currentDayDogFood = int.Parse(Console.ReadLine());
  21.                 eatenDogFood += currentDayDogFood;
  22.                 int currentDayCatFood = int.Parse(Console.ReadLine());
  23.                 eatenCatFood += currentDayCatFood;
  24.                 eatenFood = eatenDogFood + eatenCatFood;
  25.                 if (dayCounter % 3 == 0)
  26.                 {
  27.                     buscuitPerday += ((currentDayCatFood + currentDayDogFood) * 0.1);
  28.                 }
  29.             }
  30.             Console.WriteLine($"Total eaten biscuits: {Math.Round(buscuitPerday)}gr.");
  31.             Console.WriteLine($"{eatenFood / totalFood * 100:f2}% of the food has been eaten.");
  32.             Console.WriteLine($"{eatenDogFood / eatenFood * 100:f2}% eaten from the dog.");
  33.             Console.WriteLine($"{eatenCatFood / eatenFood * 100:f2}% eaten from the cat.");
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement