ivanov_ivan

PigyBank

Mar 11th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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 PigyBank
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int thePriceOfTheTank = int.Parse(Console.ReadLine());
  14.             int paryDaysInAMonth = int.Parse(Console.ReadLine());
  15.             int normalDays = 30 - paryDaysInAMonth;
  16.             int a = normalDays * 2;
  17.             int spentOnParyDays = paryDaysInAMonth * 5;
  18.             int levaPerMonth = a - spentOnParyDays;
  19.             double month = (double)thePriceOfTheTank / levaPerMonth;
  20.             //decimal x = ( Math.Ceiling(( ( month / 12 ) - ( (int)month / 12 ) ) * 12) );
  21.             int years = (int)Math.Ceiling(month) / 12;
  22.             int months = (int)Math.Ceiling(month) % 12;
  23.  
  24.  
  25.             if(month > 0)
  26.             {
  27.                 Console.WriteLine("{0} years, {1} months" , years , months);
  28.             }
  29.             else
  30.             {
  31.                 Console.WriteLine("never");
  32.             }
  33.         }
  34.     }
  35. }
Add Comment
Please, Sign In to add comment