a1m

Piggy Bank

a1m
Feb 25th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. class piggybank
  4. {
  5.     static void Main()
  6.     {
  7.         int pTank = int.Parse(Console.ReadLine());
  8.         int pDays = int.Parse(Console.ReadLine());
  9.         int pBank = ((30 - pDays) * 2) - (pDays * 5);
  10.         if (pDays >= 9)
  11.         {
  12.             Console.WriteLine("never");
  13.             return;
  14.         }
  15.         double totaMonths = (double)pTank / pBank;
  16.         int result = (int)Math.Ceiling(totaMonths);
  17.  
  18.  
  19.         int years = result / 12;
  20.         int months2 = result % 12;
  21.  
  22.         Console.WriteLine("{0} years, {1} months", years, months2);
  23.     }
  24. }
Add Comment
Please, Sign In to add comment