Compound interest program inside a loop to show end table problem!!

  • Thread starter Thread starter OhhBnertt
  • Start date Start date
O

OhhBnertt

Guest
Hey guys I have to complete this program for a compound interest calculator and need to have it loop 5 times in order to show the user a table at the end with their balances. Ex. Year 1 $5060, Year 2 $6000 and so on but am stuck trying to code it using a for loop. Here's what I have so far. If you guys could help me out with this I would really appreciate it!!

Console.WriteLine("----------------------");
Console.WriteLine("|Compound Interest App|");
Console.WriteLine("----------------------");
Console.WriteLine("This program is used to calculate the future value

for (int i = 1; i < years; i++)
{

double principal;//The principal amount before interest
double futurevalue;//The value after interest
double annualint;//The annual interest rate
double years = 0;//How many years interest is earned




Console.Write("Please enter investment amount: ");
principal = Convert.ToDouble(Console.ReadLine());

Console.Write("Please enter annual interest rate in percentage: ");
annualint = Convert.ToDouble(Console.ReadLine());
annualint /= 100;

Console.Write("Please enter the number of years : ");
years = Convert.ToDouble(Console.ReadLine());

futurevalue = principal * Math.Pow((1 + annualint),//math equation
(years));


Console.WriteLine($"Year Balance");
Console.WriteLine($"{i} {futurevalue}");
}

Continue reading...
 
Back
Top