Advertisement
silvana1303

pets

Mar 24th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 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. namespace silvanadoc
  7. {
  8.     class silvanadoc
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int daysOut = int.Parse(Console.ReadLine());
  13.             int foodKept = int.Parse(Console.ReadLine());
  14.             double dogFood = double.Parse(Console.ReadLine());
  15.             double catFood = double.Parse(Console.ReadLine());
  16.             double turtleFood = double.Parse(Console.ReadLine());
  17.  
  18.             var dogSum = daysOut * dogFood;
  19.             var catSum = catFood * daysOut;
  20.             var turtleSum = (turtleFood / 1000) * daysOut;
  21.  
  22.             var allFood = dogSum + catSum + turtleSum;
  23.  
  24.             var foodLeft = foodKept - allFood;
  25.             var foodMore = allFood - foodKept;
  26.  
  27.             if (foodKept >= allFood)
  28.             {
  29.                 Console.WriteLine($"{Math.Floor(foodLeft)} kilos of food left.");
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine($"{Math.Ceiling(foodMore)} more kilos of food are needed.");
  34.             }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement