Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 5a32fe6c authored by Edouard Mangel's avatar Edouard Mangel
Browse files

implement IRateFetcher interface

parent c3e42346
No related branches found
No related tags found
No related merge requests found
No preview for this file type
File deleted
File deleted
No preview for this file type
namespace Credit;
public class MortgageSimulator
{
public static Amount ComputeMonthlyPayment(Amount borrowedAmount, int durationInMonth, decimal rate)
{
if (borrowedAmount.Value * (int) Math.Pow(10, borrowedAmount.Currency.Precision) < 5000000) {
throw new ArgumentOutOfRangeException(nameof(borrowedAmount), "Can't borrow so little capital.");
}
double numerator = (double)(borrowedAmount * rate / 12);
double denominator = 1 - Math.Pow((double)(1 + rate / 12), - durationInMonth);
double value = numerator / denominator;
return new Amount(value, borrowedAmount.Currency);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment