Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.CatShelterбее
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double foodPerCat = double.Parse(Console.ReadLine());
  10. string command = "";
  11. double foodPerCatInGrams = foodPerCat * 1000;
  12. double foodGrams = 0;
  13. double foodGramsSum = 0;
  14.  
  15. while (command != "Adopted")
  16. {
  17. command = Console.ReadLine();
  18. if(command == "Adopted")
  19. {
  20. break;
  21. }
  22. foodGrams = double.Parse(command);
  23. foodGramsSum += foodGrams;
  24. }
  25.  
  26. double leftovers = foodPerCatInGrams - foodGramsSum;
  27. double foodNeeded = foodGramsSum - foodPerCatInGrams;
  28.  
  29. if (foodPerCatInGrams >= foodGramsSum)
  30. {
  31. Console.WriteLine($"Food is enough! Leftovers: {leftovers} grams.");
  32. }
  33. else
  34. {
  35. Console.WriteLine($"Food is not enough. You need {foodNeeded} grams more.");
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement