Advertisement
Guest User

Untitled

a guest
Jan 27th, 2017
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 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.  
  7. namespace _02.Pets
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int days = int.Parse(Console.ReadLine());
  14.             double foodAvailable = int.Parse(Console.ReadLine());
  15.             double dogFoodPerDay = double.Parse(Console.ReadLine());
  16.             double catFoodPerDay = double.Parse(Console.ReadLine());
  17.             double turtleFoodPerDay = double.Parse(Console.ReadLine()) / 1000;
  18.  
  19.             double foodNeeded = (dogFoodPerDay + catFoodPerDay + turtleFoodPerDay) * days;
  20.             if (foodNeeded <= foodAvailable)
  21.             {
  22.                 foodAvailable -= foodNeeded;
  23.                 Console.Write("{0} kilos of food left.", Math.Floor(foodAvailable));
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine("{0} more kilos of food are needed.", Math.Ceiling(foodNeeded - foodAvailable));
  28.             }
  29.  
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement