Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _05._Care_of_Puppy
- {
- class Program
- {
- static void Main(string[] args)
- {
- int availableFood = int.Parse(Console.ReadLine());
- int availableFoodInGrams = availableFood * 1000;
- String command = Console.ReadLine();
- int totalEaten = 0;
- while (command != "Adopted")
- {
- int grams = int.Parse(command);
- totalEaten += grams;
- command = Console.ReadLine();
- }
- if (availableFoodInGrams >= totalEaten)
- {
- int leftFood = availableFoodInGrams - totalEaten;
- Console.WriteLine($"Food is enough! Leftovers: {leftFood} grams.");
- }
- else
- {
- int needFood = totalEaten - availableFoodInGrams;
- Console.WriteLine($"Food is not enough. You need {needFood} grams more.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement