Advertisement
silvana1303

care of puppy

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