I am totally confused on how to write the formula for a compound interest. I thought that it would be A = P (1+r/n)^n+t, but the rates vary between each performance year and I wasn't taught how to do that in code. Please help.
#include <iostream>
#include <math.h>
usingnamespace std;
int main(void)
{
double Principal;
double Perf1;
double Perf2;
double Perf3;
double Perf4;
double FinVal;
cout.setf(ios::showpoint);
cout.setf(ios::fixed);
cout.precision(2);
cout << "Please enter the initial amount invested: $ ";
cin >> Principal;
cout << "Please enter the performance for year #1: % ";
cin >> Perf1;
cout << "Please enter the performance for year #2: % ";
cin >> Perf2;
cout << "Please enter the performance for year #3: % ";
cin >> Perf3;
cout << "Please enter the performance for year #4: % ";
cin >> Perf4;
FinVal = (1+ Perf4/1)^4;
cout << "The final value of the stock is: $ " << FinVal << endl << endl;
return 0;
}