-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFixedLoan.cpp
69 lines (58 loc) · 2.19 KB
/
FixedLoan.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream> //used for input outputs
#include <string> //used to include strings
using namespace std;
#include "FixedLoan.h"
#include <cmath>
float FixedLoan::interestCal(float amount, float interest, int num_years)
//function to calculate repayments
{
float months, intrest_used, primary, temp, deno, num, constant, x;
int y, i, n;
float totalrepayment;
i = 1;
constant = 1;
primary = amount;
intrest_used = interest;
y = num_years;
x = intrest_used / 1200;
n = (y * 12);
temp = 1 + (x);
while (i <= n)
{
constant = constant * temp;
i++;
}
num = constant * primary * (x);
deno = constant - 1;
months = num / deno;
monthly_amount = months;
totalrepayment = monthly_amount * num_years * 12;
totalInterest = totalrepayment - amount;
cout << "\nAt an interest rate of " << interest << "% the details of the repayments are: " << endl;
cout << "\nTotal Loan repayment is: $" << round(totalrepayment) << endl;
cout << "\nTotal amount of interest paid is: $" << round(totalInterest) << endl;
cout << "\nYour principal and interest repayments would be $" << round(monthly_amount) << " per month" << endl;
return round(monthly_amount);
}
void FixedLoan::Eligibility(float limit, int life, int salary, float initial){
if (limit <= 1000000 && life <= 30 && salary >= 30000 && initial >= (0.2 * limit))
{
if (system("CLS")) system("clear");
cout << "\nGREAT! YOU ARE CONDITIONALLY APPROVED FOR THIS FIXED LOAN!" << endl;
Currentinterest = 5.73;
interestCal(limit, 5.73, life);
continueprogram();
}
else
{
if (system("CLS")) system("clear");
cout << "\nSORRY! YOUR LOAN APPLICATION WAS UNSUCCESSFUL. PLEASE TRY AGAIN LATER!" << endl;
AccNum = 51728;
Currentinterest = 2.73;
type = "fixed";
LoanBalance = 560000;
LoanLife = 15;
AccName = "UserName";
continueprogram();
}
}