Simple or compound interest calculation.
$ dotnet add package InterestExtensionsThis extension facilitates the calculation of both simple interest and compound interest.
To install the package via NuGet, you can use the following command:
dotnet add package InterestExtensions
You can also visit the NuGet package page for more information and to download the package.
using InterestExtension;
using InterestExtension.Enums;
decimal principal = 100m;
decimal interestRate = 0.004m;
int period = 7;
// Calculate simple interest (final amount)
decimal simple = principal.CalculateSimpleInterest(interestRate, period);
// Calculate simple interest amount (just the interest earned)
decimal simpleAmount = principal.CalculateSimpleInterestAmount(interestRate, period);
// Calculate compound interest (final amount, annual compounding)
decimal compound = principal.CalculateCompoundInterest(interestRate, period);
// Calculate compound interest (monthly compounding)
decimal compoundMonthly = principal.CalculateCompoundInterest(interestRate, period, InterestPeriod.Monthly);
// Calculate only the interest earned
decimal earned = principal.CalculateCompoundInterestAmount(interestRate, period, InterestPeriod.Daily);
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.