Advertisement
desislava_topuzakova

05. Care of Puppy

Mar 31st, 2020
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._Care_of_Puppy
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int availableFood = int.Parse(Console.ReadLine());
  10.             int availableFoodInGrams = availableFood * 1000;
  11.  
  12.             String command = Console.ReadLine();
  13.             int totalEaten = 0;
  14.  
  15.             while (command != "Adopted")
  16.             {
  17.                 int grams = int.Parse(command);
  18.                 totalEaten += grams;
  19.                 command = Console.ReadLine();
  20.             }
  21.  
  22.             if (availableFoodInGrams >= totalEaten)
  23.             {
  24.                 int leftFood = availableFoodInGrams - totalEaten;
  25.                 Console.WriteLine($"Food is enough! Leftovers: {leftFood} grams.");
  26.             }
  27.             else
  28.             {
  29.                 int needFood = totalEaten - availableFoodInGrams;
  30.                 Console.WriteLine($"Food is not enough. You need {needFood} grams more.");
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement