C# program to find Compound Interest
Program
using System;
namespace CompoundInterest
{
class Program
{
static void Main(string[] args)
{
float p,t,r;
float amount, ci;
Console.WriteLine("Enter principal amount, time and rate of interest to calculate compound interest\n");
Console.Write("Principal amount:\t");
p = float.Parse(Console.ReadLine());
Console.Write("Time:\t");
t = float.Parse(Console.ReadLine());
Console.Write("Rate of Interest:\t");
r = float.Parse(Console.ReadLine());
amount = p * (float)Math.Pow((1 + r / 100), t);
ci = amount - p;
Console.WriteLine("Compound Interest:\t{0}", ci);
Console.WriteLine("Total Amount Payable:\t{0}", amount);
}
}
}
Output
Enter principal amount, time and rate of interest to calculate compound interest
Principal amount: 24000.45
Time: 10.5
Rate of Interest: 9.5
Compound Interest: 38239.29
Total Amount Payable: 62239.74