-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path10.cpp
33 lines (26 loc) · 854 Bytes
/
10.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
/*
Write another version of the program from Exercise 7 so that, instead of finding the final
amount of your investment, you tell the program the final amount and it figures out how
many years it will take, at a fixed rate of interest compounded yearly, to reach this
amount.
*/
//author @Nishant
#include<iostream>
using namespace std;
int main(){
float final_amount, amount, interest, temp;
int year=0;
cout << "Enter the final amount you want to get in particular year: ";
cin >> final_amount;
cout << "Enter the principal amount: ";
cin >> amount;
cout << "Enter the rate of interest: ";
cin >> interest;
temp = amount;
while(temp<final_amount){
temp *= (1+(interest/100));
year++;
}
cout << "It will take " << year << " years at " << interest << " of interest to reach the final amount " << final_amount << endl;
return 0;
}