Advertisement
fbinnzhivko

BookProblem

Mar 19th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         var bookPages = double.Parse(Console.ReadLine());
  8.         var campaingDays = double.Parse(Console.ReadLine());
  9.         var readPages = double.Parse(Console.ReadLine());
  10.  
  11.         var mounth = 30 - campaingDays;
  12.         var totalMounthPages = mounth * readPages;
  13.         var needTime = bookPages / totalMounthPages;
  14.         var years = needTime / 12;
  15.         var moreMounth = needTime % 12;
  16.  
  17.  
  18.         if (mounth == 0 || readPages == 0)
  19.         {
  20.             Console.WriteLine("never");
  21.         }
  22.         else
  23.         {
  24.             Console.WriteLine("{0:0} years {1:0} months", years, Math.Ceiling(moreMounth));
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement