C# program to calculate Compound Interest
In this C# program, we will take the input "Principal Amount", "Interest Rate", "Interest Compound Frequency" and "Time" from the user and calculate the simple interest.
C# program to calculate Compound Interest Code:
private static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Yellow;
double Total = 0, interestRate, years, annualCompound, PrincipalAmount;
Console.Write("Enter the Principal Amount : ");
PrincipalAmount = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the Rate of Interest : ");
interestRate = Convert.ToDouble(Console.ReadLine()) / 100;
Console.Write("Enter the Number of Years : ");
years = Convert.ToDouble(Console.ReadLine());
Console.Write("Number of Times the Interest will be Compounded : ");
annualCompound = Convert.ToDouble(Console.ReadLine());
for (int t = 1; t < years + 1; t++)
{
Total = PrincipalAmount * Math.Pow((1 + interestRate / annualCompound),
(annualCompound * t));
Console.Write("Your Total for Year {0} "+ "is {1}. \n", t, Math.Round(Total,2));
}
Console.ReadLine();
}
C# program to calculate Compound Interest Output: