Skip to content

Instantly share code, notes, and snippets.

@MladenMladenov
Created July 25, 2015 07:18
Show Gist options
  • Save MladenMladenov/66bf48fa5276ed8a0ff4 to your computer and use it in GitHub Desktop.
Save MladenMladenov/66bf48fa5276ed8a0ff4 to your computer and use it in GitHub Desktop.
using System;
class PiggyBank
{
static void Main()
{
int price = int.Parse(Console.ReadLine());
int partyDays = int.Parse(Console.ReadLine());
if (partyDays > 8)
{
Console.WriteLine("never");
}
else
{
int normalDays = 30 - partyDays;
int monthlySavings = normalDays * 2;
int monthlyExpenses = partyDays * 5;
int monthlyBalance = monthlySavings - monthlyExpenses;
double totalMonthsRequired = (double)price / monthlyBalance;
int result = (int)Math.Ceiling(totalMonthsRequired);
int years = result / 12;
int months = result % 12;
Console.WriteLine("{0} years, {1} months", years, months);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment