Advertisement
Guest User

Untitled

a guest
May 1st, 2020
1,067
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace LoopsExamTasks
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int days = int.Parse(Console.ReadLine());
  10. double foodCount = double.Parse(Console.ReadLine());
  11.  
  12. double biscuits = 0;
  13. double eatenFoodDog = 0;
  14. double eatenFoodCat = 0;
  15.  
  16. for (int i = 1; i <= days; i++)
  17. {
  18. double foodDog = double.Parse(Console.ReadLine());
  19. double foodCat = double.Parse(Console.ReadLine());
  20.  
  21. eatenFoodDog += foodDog;
  22. eatenFoodCat += foodCat;
  23.  
  24.  
  25. if (i % 3 == 0)
  26. {
  27. double currentBiscuits = (foodDog + foodCat) * 0.1;
  28. biscuits += currentBiscuits;
  29. }
  30.  
  31. }
  32. double allEatenFood = eatenFoodDog + eatenFoodCat;
  33. double percentFood = (allEatenFood / foodCount) * 100;
  34. double percentDog = (eatenFoodDog / allEatenFood) * 100;
  35. double percentCat = (eatenFoodCat / allEatenFood) * 100;
  36.  
  37. Console.WriteLine($"Total eaten biscuits: {Math.Round(biscuits)}gr.");
  38. Console.WriteLine($"{percentFood:F2}% of the food has been eaten.");
  39. Console.WriteLine($"{percentDog:F2}% eaten from the dog.");
  40. Console.WriteLine($"{percentCat:F2}% eaten from the cat.");
  41.  
  42.  
  43.  
  44.  
  45. }
  46. }
  47. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement