Advertisement
Somo4k

05.Puppy-care

Jun 9th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._PUPPYCare
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int kg = int.Parse(Console.ReadLine());
  10. string gramsFood = Console.ReadLine();
  11.  
  12. int sumFood = 0;
  13. int grams = kg * 1000;
  14.  
  15. while (gramsFood != "Adopted")
  16. {
  17. int num = int.Parse(gramsFood);
  18. sumFood += num;
  19. gramsFood = Console.ReadLine();
  20. }
  21.  
  22. if (sumFood > grams)
  23. {
  24. Console.WriteLine($"Food is not enough. You need {sumFood - grams} grams more.");
  25. }
  26. else
  27. {
  28. Console.WriteLine($"Food is enough! Leftovers: {grams - sumFood} grams.");
  29. }
  30. }
  31. }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement