Advertisement
shmekera93

Untitled

Dec 15th, 2019
107
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.  
  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.  
  16.  
  17.  
  18. double totalbiscuits = 0;
  19.  
  20.  
  21. for (int i = 0; i < days; i++)
  22. {
  23.  
  24. int foodFromDog = int.Parse(Console.ReadLine());
  25. int foodFromCat = int.Parse(Console.ReadLine());
  26.  
  27. totalDogFood = totalDogFood + foodFromDog;
  28. totalCatFood = totalCatFood + foodFromCat;
  29.  
  30. if (i + 1 % 10 == 3)
  31. {
  32. totalbiscuits = 0.10 * (foodFromDog + foodFromCat);
  33. }
  34.  
  35. }
  36.  
  37. double totalEatFood = totalCatFood + totalDogFood;
  38. double percentFromAll = totalEatFood / totalFood * 100;
  39. double percentFromDog = totalDogFood / totalEatFood * 100;
  40. double percentFromCat = totalCatFood / totalEatFood * 100;
  41.  
  42. Console.WriteLine($"Total eaten biscuits: {Math.Round(totalbiscuits)}gr.");
  43. Console.WriteLine($"{percentFromAll:F2}% of the food has been eaten.");
  44. Console.WriteLine($"{percentFromDog:F2}% eaten from the dog.");
  45. Console.WriteLine($"{percentFromCat:F2}% eaten from the cat.");
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement