GPipkov

Piggy Bank

Aug 28th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 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 PiggyBank
  8. {
  9.     class PiggyBank
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double priceOfTheTank = double.Parse(Console.ReadLine());
  14.             double partiesDays = double.Parse(Console.ReadLine());
  15.             double normalDays = 30 - partiesDays;
  16.             double savings = (normalDays * 2) - (partiesDays * 5);
  17.             double neededMonts = priceOfTheTank / savings;
  18.             double years = neededMonts / 12;
  19.             double monts = neededMonts % 12;
  20.             if (monts < 0)
  21.             {
  22.                 Console.WriteLine("never");
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine("{0} years, {1} months",Math.Floor(years) ,Math.Ceiling((double)monts));
  27.             }
  28.         }
  29.     }
  30. }
Add Comment
Please, Sign In to add comment