Advertisement
AJMitev

IsThereEnoughFood

Mar 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System;
  2. class EnoughFood
  3. {
  4. static void Main()
  5. {
  6. //Input
  7. int howManyDays = int.Parse(Console.ReadLine());
  8. int howManyFoods = int.Parse(Console.ReadLine());
  9. double dogsFood = double.Parse(Console.ReadLine());
  10. double catsFood = double.Parse(Console.ReadLine());
  11. double turtlesFood = double.Parse(Console.ReadLine());
  12.  
  13. //Logic
  14. double turtlesFoodInKilos = turtlesFood / 1000;
  15. double foodEaten = (dogsFood + catsFood + turtlesFoodInKilos)*howManyDays;
  16. double result = howManyFoods - foodEaten;
  17. bool isThereEnoughFood = howManyFoods >= foodEaten;
  18.  
  19. //Output
  20. if (isThereEnoughFood)
  21. {
  22. Console.WriteLine($"{Math.Floor(result)} kilos of food left.");
  23. }
  24. else
  25. {
  26. result = Math.Abs(result);
  27. Console.WriteLine($"{Math.Ceiling(result)} more kilos of food are needed.");
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement