iliya87

01.PiggyBank

Mar 24th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. class PiggyBank
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int priceOfTank = int.Parse(Console.ReadLine());
  8.         int  partyDays = int.Parse(Console.ReadLine());
  9.  
  10.        
  11.         int notsaving = partyDays * 5;
  12.         int saving = (30 - partyDays) * 2;
  13.         int normalMonth =  (30 - partyDays) * 2  - notsaving;
  14.        
  15.  
  16.  
  17.         if (notsaving >= saving)
  18.  
  19.         {
  20.             Console.WriteLine("never");
  21.         }
  22.         else
  23.         {
  24.  
  25.             double  count = (double)priceOfTank / (double)normalMonth;
  26.             count = Math.Ceiling(count);
  27.             double years =  count / 12;
  28.             double monts = count % 12;
  29.             Console.WriteLine("{0} years, {1} months",Math.Floor(years),Math.Ceiling(monts));
  30.         }
  31.        
  32.     }
  33. }
Add Comment
Please, Sign In to add comment