I am relatively new to C++, but I was wondering why I was getting off calculations in my interest equation. I need to display the interest acquired after 5 years, displaying each individual year's income. It has been producing numbers in the ten-thousands (33632) I am entering $1000 as the principle amount. Thanks for help in advance!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int main () {
double r = 1.02;
double b = 0.0;
double p = 0.0;
int t = 1;
cout << "Please enter the amount of money in the savings account: ";
cin >> p;
while (t <= 5) {
b = p * pow(1 + r, t);
cout << fixed << setprecision(2);
cout << "After " << t << " years $" << b << " has been accumulated " << endl;
t++;
}