Spocoman

06. Pets

Nov 16th, 2021 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Pets
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int day = int.Parse(Console.ReadLine());
  10.             double foodKg = double.Parse(Console.ReadLine());
  11.             double dogKg = double.Parse(Console.ReadLine());
  12.             double catKg = double.Parse(Console.ReadLine());
  13.             double turtleGr = double.Parse(Console.ReadLine());
  14.  
  15.             double totalKg = dogKg * day + catKg * day + turtleGr / 1000 * day;
  16.             if (foodKg >= totalKg)
  17.             {
  18.                 Console.WriteLine($"{Math.Floor(foodKg - totalKg)} kilos of food left.");
  19.             }
  20.             else
  21.             {
  22.                 Console.WriteLine($"{Math.Ceiling(totalKg - foodKg)} more kilos of food are needed.");
  23.             }
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment