petarkobakov

Food for pets

Apr 29th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Food_for_Pets
  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. double eatenbydog=0;
  12. double eatenbycat=0;
  13. double bisquit = 0;
  14. double totalfoodeaten = 0;
  15.  
  16. for (int i = 1; i <=days; i++)
  17. {
  18. double dogfood = double.Parse(Console.ReadLine());
  19. double catfood = double.Parse(Console.ReadLine());
  20. double foodeatenperday = dogfood + catfood;
  21. eatenbydog += dogfood;
  22. eatenbycat += catfood;
  23. totalfoodeaten = eatenbydog+eatenbycat;
  24.  
  25. if (i %3==0)
  26. {
  27. bisquit += foodeatenperday * 0.10;
  28. }
  29. }
  30. double percenteaten = totalfoodeaten / totalfood * 100;
  31. double percenteatenbydog = eatenbydog/totalfoodeaten*100;
  32. double percenteatenbycat = eatenbycat/totalfoodeaten*100;
  33.  
  34. Console.WriteLine($"Total eaten biscuits: {Math.Round(bisquit)}gr.");
  35. Console.WriteLine($"{percenteaten:f2}% of the food has been eaten.");
  36. Console.WriteLine($"{percenteatenbydog:f2}% eaten from the dog.");
  37. Console.WriteLine($"{percenteatenbycat:f2}% eaten from the cat.");
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment