-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinear_Recurrence.cpp
More file actions
123 lines (111 loc) · 2.74 KB
/
Linear_Recurrence.cpp
File metadata and controls
123 lines (111 loc) · 2.74 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Name - Mohit Jaiswal
Roll No. - 57
Practical No. 14
*/
#include <iostream>
using namespace std;
float amount_return(float balance,float intrest_rate,int duration) //Linear recurrence relation
{
if(duration==0)
{
return balance;
}
else
{
float intrest=balance*(intrest_rate/100);
return amount_return(balance+intrest,intrest_rate,duration-1);
}
}
int main()
{
int time,choice,intrest_rate,amount;
char ch;
do
{
cout<<endl;
cout<<"*Loan list*"<<endl;
cout<<"\n1.Education loan \n2.Home loan \n3.Car loan"<<endl;
cout<<"4.Exit"<<endl;
cout<<"\nEnter your choice"<<endl;
cin>>choice;
switch(choice)
{
case 1: //Education loan
cout<<"Amount \t\t\t\t intrest rate"<<endl;
cout<<"0-10000 Rs \t\t\t 5%"<<endl;
cout<<"10000-50000 Rs \t\t\t 7%"<<endl;
cout<<"More than 50000 Rs \t\t 9%"<<endl;
cout<<"Enter the amount"<<endl;
cin>>amount;
cout<<"Enter the time"<<endl;
cin>>time;
if(amount<=10000)
{
intrest_rate=5;
}
else if(amount>10000 && amount<50000)
{
intrest_rate=7;
}
else
{
intrest_rate=9;
}
cout<<"You have to repay amount is : "<<amount_return(amount,intrest_rate,time)<<" after "<<time<<" year"<<endl;
break;
case 2: //Home Loan
cout<<"Amount \t\t\t\t intrest rate"<<endl;
cout<<"0-10000 Rs \t\t\t 9%"<<endl;
cout<<"10000-50000 Rs \t\t\t 10%"<<endl;
cout<<"More than 50000 Rs \t\t 15%"<<endl;
cout<<"Enter the amount"<<endl;
cin>>amount;
cout<<"Enter the time"<<endl;
cin>>time;
if(amount<=10000)
{
intrest_rate=9;
}
else if(amount>10000 && amount<50000)
{
intrest_rate=10;
}
else
{
intrest_rate=15;
}
cout<<"You have to repay amount is : "<<amount_return(amount,intrest_rate,time)<<" after "<<time<<" year"<<endl;
break;
case 3: //Car Loan
cout<<"Amount \t\t\t\t intrest rate"<<endl;
cout<<"0-10000 Rs \t\t\t 12%"<<endl;
cout<<"10000-50000 Rs \t\t\t 15%"<<endl;
cout<<"More than 50000 Rs \t\t 19%"<<endl;
cout<<"Enter the amount"<<endl;
cin>>amount;
cout<<"Enter the time"<<endl;
cin>>time;
if(amount<=10000)
{
intrest_rate=12;
}
else if(amount>10000 && amount<50000)
{
intrest_rate=15;
}
else
{
intrest_rate=19;
}
cout<<"You have to repay amount is : "<<amount_return(amount,intrest_rate,time)<<" after "<<time<<" year"<<endl;
break;
case 4:
exit(0);
break;
default:
cout<<"Invalid choice"<<endl;
}
}while(choice<5);
return 0;
}