fbinnzhivko

01.00 Piggy Bank

Mar 12th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.  
  8.         double price = double.Parse(Console.ReadLine());
  9.         double partyDays = double.Parse(Console.ReadLine());
  10.  
  11.         double savings = ((30 - partyDays) * 2) - (5 * partyDays);
  12.         //Console.WriteLine(monthlyBalance);
  13.  
  14.         if (savings < 0) { Console.WriteLine("never");}
  15.         else
  16.         {
  17.             double neededMonhts = Math.Ceiling(price / savings);
  18.  
  19.             //Console.WriteLine(years);
  20.             double years  = neededMonhts / 12;
  21.  
  22.             //Console.WriteLine(monts );
  23.             double mounts = neededMonhts % 12;
  24.  
  25.             //Console.WriteLine(monts);
  26.             Console.WriteLine("{0:f0} years, {1:f0} months",Math.Floor(years), mounts);
  27.         }
  28.     }
  29. }
Add Comment
Please, Sign In to add comment