Hello fellow coders!
I was wondering if someone could help me with looping the following.
I need the "deposit" to be looped with the compound interest "rate" so that it totals to the "goal".
Sample output:
Enter annual deposit amount!:
How much are you looking to save?:
Enter your rate!:
The computer gives back these results:
Your balance will be (amount)in (number of) years including earned interest!
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>
#include <string>
#include <cmath>
using namespace std;
int main ()
{
float deposit;
cout << "Enter annual deposit amount!: ";
cin >> deposit;
float goal;
cout << "How much are you looking to save?: ";
cin >> goal;
float rate;
cout << "Enter your rate!: ";
cin >> rate;
float balance, comp;
comp = deposit * (rate/100);
balance = comp+deposit;
cout << balance;
}
|
Last edited on