koksibg

Pets

Nov 20th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Pets
  4. {
  5.     class Pets
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int day = int.Parse(Console.ReadLine());
  10.             int leftFood = int.Parse(Console.ReadLine()); //kg
  11.             double foodForDog = double.Parse(Console.ReadLine()); //kg
  12.             double foodForCat = double.Parse(Console.ReadLine()); //kg
  13.             double foodForTurtle = double.Parse(Console.ReadLine()); //gram
  14.             double neededFoodsForDog = day * foodForDog;
  15.             double neededFoodsForCat = day * foodForCat;
  16.             double neededFoodsForTurtle = day * foodForTurtle / 1000;
  17.             double sumFoodForAnimal = neededFoodsForDog + neededFoodsForCat + neededFoodsForTurtle;
  18.             double result = Math.Abs(leftFood - sumFoodForAnimal);
  19.             if (sumFoodForAnimal <= (double)leftFood) Console.WriteLine($"{Math.Floor(result)} kilos of food left.");
  20.             else Console.WriteLine($"{Math.Ceiling(result)} more kilos of food are needed.");
  21.         }
  22.     }
  23. }
Add Comment
Please, Sign In to add comment