Advertisement
AlexandrP

Untitled

Dec 18th, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Security.Cryptography;
  3.  
  4. namespace ConsoleApp12
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.  
  11.             int food = int.Parse(Console.ReadLine());
  12.             int foodInGrams = food * 1000;
  13.             int totalFood = 0;
  14.             string command = Console.ReadLine();
  15.  
  16.             while (command != "Adopted")
  17.             {
  18.                 int foodEaten = int.Parse(command);
  19.                 totalFood += foodEaten;
  20.                 command = Console.ReadLine();
  21.             }
  22.  
  23.             if (totalFood <= foodInGrams)
  24.             {
  25.                 Console.WriteLine($"Food is enough! Leftovers: {foodInGrams - totalFood} grams.");
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine($"Food is not enough. You need {totalFood - foodInGrams} grams more.");
  30.             }
  31.  
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement