Aliendreamer

pets from 20.11.2016 exam

Mar 17th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 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 pets
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             //input
  15.             double days = double.Parse(Console.ReadLine());
  16.             double kgFood = double.Parse(Console.ReadLine());
  17.             double  dogfood =double.Parse(Console.ReadLine());
  18.             double catFood = double.Parse(Console.ReadLine());
  19.             double turtleFood = double.Parse(Console.ReadLine());
  20.  
  21.             //logic
  22.             double turtlefoodkg= turtleFood / 1000;
  23.             double dogfoodTotal = days * dogfood;
  24.             double catfoodtotal = days * catFood;
  25.             double turtlefoodtotal = days* turtlefoodkg ;
  26.             double totalfood = dogfoodTotal + catfoodtotal + turtlefoodtotal;
  27.             double leftfood = Math.Abs(kgFood - totalfood);
  28.          
  29.  
  30.             if(totalfood<kgFood)
  31.             {
  32.                 Console.WriteLine("{0} kilos of food left.",Math.Floor(leftfood));
  33.             }
  34.             else if(totalfood>kgFood)
  35.             {
  36.                 Console.WriteLine("{0} more kilos of food are needed.}",Math.Ceiling(leftfood));
  37.             }
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment