diff options
| author | gonzo <gonzo@toniatuh.com> | 2026-09-05 11:11:35 +0200 |
|---|---|---|
| committer | gonzo <gonzo@toniatuh.com> | 2026-09-05 11:11:35 +0200 |
| commit | 0a3cab28ce353e9cf0caa8b202e433a0404a82e1 (patch) | |
| tree | 26c15b8f18771e8a911460bab5711d8b0ddd376b /straight_line_loan.c | |
| parent | 93658108c0951e8b03cdd574ec436c1acb821c7b (diff) | |
| download | loan_calc-0a3cab28ce353e9cf0caa8b202e433a0404a82e1.tar.gz | |
Diffstat (limited to 'straight_line_loan.c')
| -rw-r--r-- | straight_line_loan.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/straight_line_loan.c b/straight_line_loan.c index 024fd49..1f6660c 100644 --- a/straight_line_loan.c +++ b/straight_line_loan.c @@ -1,8 +1,10 @@ #include "loans.h" contract *sl_init(int n, int d, double r, double P) { - if ((n < 0)) return NULL; - if ((d >= n)||(d < 0)) return NULL; + if ((n < 0)) + return NULL; + if ((d >= n) || (d < 0)) + return NULL; contract *c = (contract *)calloc(1, sizeof(contract)); c->n = (unsigned int)n; c->d = (unsigned int)d; @@ -16,7 +18,8 @@ double sl_update(contract *c) { if (c->k > c->n) return 0.0; - if (c->k == c->d) c->D = c->P/(double)(c->n - c->k); + if (c->k == c->d) + c->D = c->P / (double)(c->n - c->k); c->k++; c->I = c->r * c->P; @@ -31,6 +34,4 @@ double sl_update(contract *c) { return c->A; } -void sl_free(contract *c) { - free(c); -} +void sl_free(contract *c) { free(c); } |
