Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- //INPUT
- int boughtFoodKilograms = int.Parse(Console.ReadLine());
- //CHANGEABLE INPUT
- int boughtFoodGrams = boughtFoodKilograms * 1000;
- string command = null;
- int eatenFood = 0;
- int eatenFoodSum = 0;
- //CALCULATIONS
- while ((command = Console.ReadLine()) != "Adopted")
- {
- eatenFood = int.Parse(command);
- eatenFoodSum += eatenFood;
- }
- if (eatenFoodSum > boughtFoodGrams)
- {
- Console.WriteLine($"Food is not enough. You need {eatenFoodSum - boughtFoodGrams} grams more.");
- return;
- }
- else
- {
- Console.WriteLine($"Food is enough! Leftovers: {boughtFoodGrams - eatenFoodSum} grams.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement