Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06.CatShelterбее
- {
- class Program
- {
- static void Main(string[] args)
- {
- double foodPerCat = double.Parse(Console.ReadLine());
- string command = "";
- double foodPerCatInGrams = foodPerCat * 1000;
- double foodGrams = 0;
- double foodGramsSum = 0;
- while (command != "Adopted")
- {
- command = Console.ReadLine();
- if(command == "Adopted")
- {
- break;
- }
- foodGrams = double.Parse(command);
- foodGramsSum += foodGrams;
- }
- double leftovers = foodPerCatInGrams - foodGramsSum;
- double foodNeeded = foodGramsSum - foodPerCatInGrams;
- if (foodPerCatInGrams >= foodGramsSum)
- {
- Console.WriteLine($"Food is enough! Leftovers: {leftovers} grams.");
- }
- else
- {
- Console.WriteLine($"Food is not enough. You need {foodNeeded} grams more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement