Advertisement
nevenailievaa

05.PuppyCare

Nov 19th, 2022
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //INPUT
  10.             int boughtFoodKilograms = int.Parse(Console.ReadLine());
  11.  
  12.             //CHANGEABLE INPUT
  13.             int boughtFoodGrams = boughtFoodKilograms * 1000;
  14.             string command = null;
  15.             int eatenFood = 0;
  16.             int eatenFoodSum = 0;
  17.  
  18.             //CALCULATIONS
  19.             while ((command = Console.ReadLine()) != "Adopted")
  20.             {
  21.                 eatenFood = int.Parse(command);
  22.                 eatenFoodSum += eatenFood;
  23.             }
  24.  
  25.             if (eatenFoodSum > boughtFoodGrams)
  26.             {
  27.                 Console.WriteLine($"Food is not enough. You need {eatenFoodSum - boughtFoodGrams} grams more.");
  28.                 return;
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine($"Food is enough! Leftovers: {boughtFoodGrams - eatenFoodSum} grams.");
  33.             }
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement