Advertisement
Terziyski

ReadBooks

Feb 18th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 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 Exams_26AprilMorning
  8. {
  9.     class ReadBook
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int pagesOfBook = int.Parse(Console.ReadLine());
  14.             int campingDays = int.Parse(Console.ReadLine());
  15.             int pagesReadStefan = int.Parse(Console.ReadLine());
  16.  
  17.             int month = 30;
  18.             int year = 12;
  19.  
  20.             double leftReadDays = month - campingDays;
  21.             double readPerMonth = leftReadDays * pagesReadStefan;
  22.             double needTimeForReading = pagesOfBook / readPerMonth;
  23.             double inYears = needTimeForReading / year;
  24.  
  25.  
  26.  
  27.             if (campingDays == month || pagesReadStefan == 0)
  28.             {
  29.                 Console.WriteLine("never");
  30.             }
  31.             else if (needTimeForReading < 12)
  32.             {
  33.  
  34.                 Console.WriteLine($"0 years {Math.Ceiling(needTimeForReading)} months");
  35.             }
  36.             else
  37.             {
  38.                 double leftMonths = needTimeForReading % 12;
  39.  
  40.  
  41.                 Console.WriteLine($"{(int)inYears} years {Math.Ceiling(leftMonths)} months");
  42.  
  43.             }
  44.  
  45.  
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement