Aligning Decimal Points

I would like to know how to align demical points in a loop - a for loop to be exact.

Here is the program. The inputs are .01, 36, and 10000.00.

void values(double, int, double);

int main()
{
double monthlyRate,
loanAmount,
payBack,
interestPaid,
payment = 332.14;
int numPayments;

cout << "Enter the monthly interest rate: ";
cin >> monthlyRate;
cout << "Enter the number of payments: ";
cin >> numPayments;
cout << "Enter the loan amount: $";
cin >> loanAmount;

cout << fixed << setprecision(2)
<< "\nLoan Amount: " <<setw(12)<<"$"<<loanAmount <<"\n"
<< "Monthly Interest Rate: " <<setprecision(0)<<setw(15) <<monthlyRate * 100<<"%"<<"\n"
<< "Number of Payments: " <<setw(20) <<numPayments <<"\n";
values(monthlyRate, numPayments, loanAmount);
payBack = payment * 36;
interestPaid = payBack - loanAmount;
cout << "\nAmount Paid Back: $" <<payBack <<"\n"
<< "Interest Paid: $ " <<interestPaid <<"\n";
system("pause");
}

void values(double Rate, int N, double L)
{
double payment,
interest,
principal;

cout <<"\n\n Payment "<<"Principal "<<"Interest "<<"Remaining Loan Amount"<<"\n";
cout <<" --------------------------------------------------------\n";

for (int i = 1; i <= 36; i++)
{
L;
payment = ((Rate * pow(1 + Rate, N)) / (pow(1 + Rate, N) - 1)) * L;
N--;
interest = L * Rate;
principal = payment - interest;
L -= principal;

if (i < 10)
cout << fixed <<setprecision(2)
<< "Month" <<" "<<i<<" $"<<payment<<" $"<<principal<<" $"<<interest<<" $"<<L<<"\n";
else
cout<< fixed <<setprecision(2)
<< "Month" <<" "<<i<<" $"<<payment<<" $"<<principal<<" $"<<interest<<" $"<<L<<"\n";
}
}
I know the output will have horrible spacing, but I just want to know how to align my decimals. Thank you.
Topic archived. No new replies allowed.