Can you please explain to me what you are trying to do with these lines
double (dollars <=1 || dollars >100000);
double (rate <.1 || rate > 99) ;
Are you trying to input if they are within those ranges?
You're going to need a while loop or do/while.
1 2 3 4 5 6
|
do
{
cout << "Enter interest rate(1% to 99% ): ";
cin >> rate;
} while( rate < 0.1 || rate > 99 );
|
Same concept for the other one.
Also I do not under stand this if statement.
if (year<1 || year>50);
That says..if true do nothing.
Are you trying to validate like earlier?
If so do as mentioned above.
What are you trying to do with
dollar < 1;
?
Also how did you get that formula you are using from the assignment?
Your assignment clearly says
1) Get a monthly deposit
2) Get an [b]annual[/code] interest rate
3) Check the amount after the amount of years
You have the correct inputs except you never said it was annual.
You misunderstood his formula
The formula he got it from is
A = P( 1 + r/n )
nt
Basically I have no idea where he came up with the magical 1200 unless he has a fixed time or something.
I would do something like this
To be honest You don't even need a loop really
You could simply do something like this
1 2 3 4
|
double result = 0.0;
const int MONTHS = 12;
result = dollars * pow( ( 1 + RATE / MONTHS ) , ( MONTHS * TIME ) );
|
Or modify it to use a loop.