Advertisement
Niicksana

Pets

Dec 11th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 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 _2.Pets
  8. {
  9.     class Pets
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             // Exam - 20 November 2016 - Morning
  15.             int days = int.Parse(Console.ReadLine());
  16.             int food = int.Parse(Console.ReadLine());
  17.             double dog = double.Parse(Console.ReadLine());
  18.             double cat = double.Parse(Console.ReadLine());
  19.             double turtle = double.Parse(Console.ReadLine());
  20.  
  21.             double foodDog = days * dog;
  22.             double foodCat = days * cat;
  23.             double foodTurtle = days * turtle / 1000;
  24.  
  25.             double foodEaten = foodDog + foodCat + foodTurtle;
  26.             double foodLeft = Math.Abs(food - foodEaten);
  27.  
  28.             if (foodEaten <= food)
  29.             {
  30.                 Console.WriteLine("{0} kilos of food left.", Math.Floor(foodLeft));
  31.             }
  32.  
  33.             else
  34.             {
  35.                 Console.WriteLine("{0} more kilos of food are needed.", Math.Ceiling(foodLeft));
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement