-
Notifications
You must be signed in to change notification settings - Fork 1
Reference Guide
To calculate simple interest using the InterestExtensions library, you can use the CalculateSimpleInterest extension method. This method takes three parameters: the principal amount, the interest rate, and the period.
Here's an example of how to use the CalculateSimpleInterest method:
decimal principal = 1000m;
decimal interestRate = 0.05m; // 5%
int period = 5; // 5 years
decimal simpleAmount = principal.CalculateSimpleInterest(interestRate, period);
Console.WriteLine($"Simple Amount: {simpleAmount}");In this example, we calculate the simple interest for a principal amount of $1000, an interest rate of 5% per year, and a period of 5 years. The result is stored in the simpleAmount variable and then printed to the console.
To calculate compound interest using the InterestExtensions library, you can use the CalculateCompoundInterest extension method. This method also takes three parameters: the principal amount, the interest rate, and the period.
Here's an example of how to use the CalculateCompoundInterest method:
decimal principal = 1000m;
decimal interestRate = 0.05m; // 5%
int period = 5; // 5 years
decimal compoundAmount = principal.CalculateCompoundInterest(interestRate, period);
Console.WriteLine($"Compound Amount: {compoundAmount}");In this example, we calculate the compound interest for the same values as before. The result is stored in the compoundAmount variable and then printed to the console.