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