public static void Main()
double principalWithInterest = 0;
Console.WriteLine(string.Format("Value is {0}:", CompoundInterest(1000, .025, 1, 5)));
while(!IsPrincipalDoubled(principal, principalWithInterest)) {
principalWithInterest = CompoundInterest(principal, 0.025, 1, year);
Console.WriteLine(string.Format("Year {0:0}, {1:C2}", year, principalWithInterest));
Console.WriteLine("Application Exit");
static bool IsPrincipalDoubled(double principal, double principalWithInterest)
return (principalWithInterest - principal) / principal >= 1;
static double CompoundInterest(double principal,
double body = 1 + (interestRate / timesPerYear);
double exponent = timesPerYear * years;
return principal * Math.Pow(body, exponent);