Advertisement
ZuRi4i

Untitled

Dec 14th, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PetFood
  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. double totalDogFood = 0;
  13. double totalCatFood = 0;
  14.  
  15.  
  16.  
  17. double totalbiscuits = 0;
  18.  
  19.  
  20. for (int i = 0; i < days; i++)
  21. {
  22.  
  23. int foodFromDog = int.Parse(Console.ReadLine());
  24. int foodFromCat = int.Parse(Console.ReadLine());
  25.  
  26. totalDogFood = totalDogFood + foodFromDog;
  27. totalCatFood = totalCatFood + foodFromCat;
  28.  
  29. if (i+1 % 3 == 3)
  30. {
  31. totalbiscuits = 0.10 * (foodFromDog + foodFromCat);
  32. }
  33.  
  34. }
  35.  
  36. double totalEatFood = totalCatFood + totalDogFood;
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement