shmekera93

Untitled

Dec 15th, 2019
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3.  
  4. namespace PetFood
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int days = int.Parse(Console.ReadLine());
  11. double totalFood = double.Parse(Console.ReadLine());
  12.  
  13. double totalDogFood = 0;
  14. double totalCatFood = 0;
  15. double totalEatFood = 0;
  16. double totalbiscuits = 0;
  17.  
  18.  
  19. for (int i = 0; i < days; i++)
  20. {
  21.  
  22. int foodFromDog = int.Parse(Console.ReadLine());
  23. int foodFromCat = int.Parse(Console.ReadLine());
  24.  
  25. totalDogFood = totalDogFood + foodFromDog;
  26. totalCatFood = totalCatFood + foodFromCat;
  27. totalEatFood = totalCatFood + totalDogFood;
  28.  
  29. if (i + 1 % 10 == 3)
  30. {
  31. totalbiscuits = 0.10 * (foodFromDog + foodFromCat);
  32. }
  33.  
  34. }
  35.  
  36.  
  37. double percentFromAll = totalEatFood / totalFood * 100;
  38. double percentFromDog = totalDogFood / totalEatFood * 100;
  39. double percentFromCat = totalCatFood / totalEatFood * 100;
  40.  
  41. Console.WriteLine($"Total eaten biscuits: {Math.Round(totalbiscuits)}gr.");
  42. Console.WriteLine($"{percentFromAll:F2}% of the food has been eaten.");
  43. Console.WriteLine($"{percentFromDog:F2}% eaten from the dog.");
  44. Console.WriteLine($"{percentFromCat:F2}% eaten from the cat.");
  45. }
  46. }
  47. }
RAW Paste Data