Ask the user to enter how much money will be deposited
If $1000 are to be deposited, the account will have the same balance
If more than $1000, find how many months it will take to double the money
First calculate the interest, add it to the $1000 then deduct $5. Then calculate the interest again but on the original value after adding interest and deducting charges. Repeat until money doubles
If less than $1000, find how many months it will take for the account to be reduced to zero
First calculate the interest, add it to the $1000 then deduct $5. Then calculate the interest again but on the original value after adding interest and deducting charges. Repeat until money becomes 0.
The interest rate is 0.5%
I wrote this program but it's not working and I can not identify the reason
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
|
#include <iostream>
using namespace std;
int main()
{
double n;
double sum=0;
int i=0;
cout<<"Please enter the amount of money you want to deposit into the account"<<endl;
cin>>n;
if (n==1000){
cout<<"The account will have the same balance at the end of each month"<<endl;
} else if (n<1000){
while (n<=0){
i=i+1;
n=((n*1.005)-5);
}
cout<<i<<endl;
} else {
while (n>=n*2){
i=i+1;
n=((n*1.005)-5);
}
cout<<i<<endl;
}
return 0;
}
|