Advertisement
Sim0o0na

06. Cat Shelter

Jun 18th, 2018
680
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. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Practice
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int kgOfFood = int.Parse(Console.ReadLine());
  14.             kgOfFood = kgOfFood * 1000;
  15.             double food = 0;
  16.             while (true)
  17.             {
  18.                 string command = Console.ReadLine();
  19.                 if (command == "Adopted")
  20.                 {
  21.                     break;
  22.                 }
  23.                 else
  24.                 {
  25.                     food += int.Parse(command);
  26.                 }
  27.  
  28.             }
  29.             if (kgOfFood >= food)
  30.             {
  31.                 Console.WriteLine($"Food is enough! Leftovers: {kgOfFood - food} grams.");
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine($"Food is not enough. You need {food - kgOfFood} grams more.");
  36.             }
  37.  
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement