-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2_5.cpp
More file actions
86 lines (84 loc) · 1.65 KB
/
2_5.cpp
File metadata and controls
86 lines (84 loc) · 1.65 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include<iostream>
#include<cmath>
using namespace std;
class bankaccount
{
private:
int id,month;
string name;
long int loan;
float rate;
double emi;
public:
bankaccount()
{
id=0;
name="unknown";
loan=0;
rate=0;
month=0;
emi=0;
}
bankaccount(int b_id,string b_name,float b_loan,float b_rate,int b_month)//parameterized
{
id=b_id;
name=b_name;
loan=b_loan;
rate=b_rate;
month=b_month;
emi=EMI(emi);
}
double EMI(double emi)
{
emi=(loan*rate*pow(1+rate,month))/(pow(1+rate,month)-1);
return emi;
}
void display()
{
double emi;
cout<<"\nLoan ID:"<<id;
cout<<"\nApplicant's name:"<<name;
cout<<"\nTotal loan amount:"<<loan;
cout<<"\nAnnual interest rate:"<<rate<<"%";
cout<<"\nLoan tenure in months:"<<month;
cout<<"\nEMI:"<<EMI(emi);
cout<<"\n";
}
};
int main()
{
int n,i;
cout<<"Enter number of applicant's:";
cin>>n;
bankaccount b[n];
for(i=0;i<n;i++)
{
if(i==0)
{
b[i]=bankaccount();
}
else
{
int id,month;
string name;
long int loan;
float rate;
cout<<"\nEnter loan ID:";
cin>>id;
cout<<"\nEnter applicant's name:";
cin>>name;
cout<<"\nEnter total loan amount:";
cin>>loan;
cout<<"\nAnnual interest rate:";
cin>>rate;
cout<<"\nLoan tenure in months:";
cin>>month;
b[i]=bankaccount(id,name,loan,rate,month);
}
}
cout<<"\n-------------Account details:--------------------";
for(i=0;i<n;i++)
{
b[i].display();
}
}