pavlinpetkov88

Pets

Nov 28th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. class Pets
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         int days = int.Parse(Console.ReadLine());
  9.         int leftFood = int.Parse(Console.ReadLine());
  10.         double foodForDog = double.Parse(Console.ReadLine());
  11.         double foodForCat = double.Parse(Console.ReadLine());
  12.         double foodForTurtle = double.Parse(Console.ReadLine());
  13.  
  14.         var dog = days * foodForDog;
  15.         var cat = days * foodForCat;
  16.         var turtle = days * (foodForTurtle / 1000);
  17.  
  18.         var foodSum = dog + cat + turtle;
  19.  
  20.         if (leftFood >= foodSum)
  21.         {
  22.             Console.WriteLine("{0} kilos of food left.", Math.Truncate(leftFood - foodSum));
  23.         }
  24.         else
  25.         {
  26.             Console.WriteLine("{0} more kilos of food are needed.", Math.Ceiling(foodSum - leftFood));
  27.         }
  28.  
  29.  
  30.     }
  31. }
Add Comment
Please, Sign In to add comment