Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _6
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. var foodInGrams = double.Parse(Console.ReadLine()) * 1000;
  10.  
  11. var eatenFood = Console.ReadLine();
  12.  
  13. while(eatenFood != "Adopted")
  14. {
  15. foodInGrams -= int.Parse(eatenFood);
  16. eatenFood = Console.ReadLine();
  17.  
  18. }
  19.  
  20. if (foodInGrams >= 0)
  21. {
  22. Console.WriteLine("Food is enough! Leftovers: {0} grams.", foodInGrams);
  23. }
  24. else
  25. {
  26. Console.WriteLine("Food is not enough. You need {0} grams more.", Math.Abs(foodInGrams));
  27. }
  28.  
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement