Code below was supposed to display interest yearly. i.e:

Year 1 $1000

Year 2 $1100

Year 3 $1210

etc

However, it's not doing that. It's listing the end year result in every year. What am I missing? My professor is inept and can't explain it to me. Any help would be greatly appreciated.

//compound interest

#include<iostream.h>

#include<iomanip.h>

#include<math.h>

main()

{

int n;

float principle,rate,amount;

cout<<"This will determine the compound interest over the entered number "

<<"of years";

cout<<"Enter the principal: $";

cin>>principle;

while (principle !=-1){

cout<<"Enter rate in decimals: ";

cin>>rate;

cout<<"Enter number of years: ";

cin>>n;

for(int year=1;year<=n;year++){

amount=principle*pow(1+rate,n);

cout<<"Year "<<year<<setw(12)<<setiosflags(ios::fixed)

<<setiosflags(ios::showpoint)

<<setprecision(2)<<"$"<<amount<<endl;

}

cout<<"Enter principle or -1 to end: ";

cin>>principle;

}

return 0;