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:

CSharp-program-to-calculate-Compound-Interest

 
We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
4 + 6 =
 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2022 CodingFusion
75 Important SQL Server queries you should know