Advertisement
NadyaMisheva

zadacha 2 test

Dec 9th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int days = int.Parse(Console.ReadLine());
  8.         int kg = int.Parse(Console.ReadLine());
  9.         double dailyF1 = double.Parse(Console.ReadLine());
  10.         double dailyF2 = double.Parse(Console.ReadLine());
  11.         double cat1 = dailyF1 * days;
  12.         double cat2 = dailyF2 * days;
  13.         double allfood = cat1 + cat2;
  14.         if(allfood <= kg)
  15.         {
  16.             Console.WriteLine("The cats are well fed.");
  17.             Console.WriteLine("{0} kilos of food left.", Math.Ceiling(kg - allfood));
  18.         }
  19.         else
  20.         {
  21.             Console.WriteLine("The cats are hungry.");
  22.             Console.WriteLine("{0} more kilos of food are needed.", Math.Floor(allfood - kg));
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement