Advertisement
Spocoman

Care of Puppy

Nov 25th, 2021 (edited)
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CareOfPuppy
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int food = int.Parse(Console.ReadLine()) * 1000;
  10.             string foodPerDay = Console.ReadLine();
  11.  
  12.             while (foodPerDay != "Adopted")
  13.             {
  14.                 food -= int.Parse(foodPerDay);
  15.                 foodPerDay = Console.ReadLine();
  16.             }
  17.  
  18.             if (food >= 0)
  19.             {
  20.                 Console.WriteLine($"Food is enough! Leftovers: {food} grams.");
  21.             }
  22.             else
  23.             {
  24.                 Console.WriteLine($"Food is not enough. You need {Math.Abs(food)} grams more.");
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement