I need my code to display Month but it seems my code is skipping month's and not displaying 1, 2 3. It's going 1 , 3 ,5 and so on. This is the code i have for it
Code:
int month = 1;
and later on the code i have month++ That's my first mistake and i'm not sure how to possibly fix it. My second mistake is my Interest Paid output. This is the code i have for it
Code:
interestPaid = loanBalance*i;
This is on the while loop, but i'm not sure why it's not displaying the correct amount. It should display for month 1 = 500.00 , Month 2 = 498.28 and Month 3 = 496.55 and so on... However my code display's something close to it, but not that. i is my monthly interest rate. My code for it seems to be fine. If i can fix this two things i'll be able to finish the project. This is my entire code, someone please help me finish it and tell me how i can fix it so that my month is displayed in 1, 2, 3, etc.... and not 1, 3, 5, etc... And why my interest is not displaying what my professor has on his output screen (i provided the first three months on top in bold) If i can fix those things i'll have the rest. Here's my entire code

#include <iostream>
#include <iomanip>


using namespace std;
int main ( )

Code:
{

	int month = 1;
	// Holds the user's amount of loan.

	double loanAmount;

	// Holds the user's interest rate.
	
	double i;

	// Holds the user's yearly Interest Rate.

	double interestRate;

	// Holds the user's interest paid every month.

	double interestPaid;
	
	// "n" means the months it will take the user to pay off the loan.

	double n;

	// Holds the variable for total months.

	double years;

	// Holds payment data.

	double monthlyPayment;

	// Holds the user Principle paid.

	double principlePaid;

	// Holds the user Loan balance.

	double loanBalance;

	// Asks the user to input how much money they took out.

	cout<<"Enter loan amount ->";
	cin>>loanAmount;

	// Asks the user to input their interest rate.

	cout<<"Enter interest rate -->";
	cin>>interestRate;
	i = (interestRate/1200);

	// Asks the user to input the number of years they are taking the loan for.

	cout<<"Enter number of years of the laon ->";
	cin>>years;
	n = years*12;
	
	// Equation that determines the user's monthly payment.

	monthlyPayment = loanAmount*(i/(1-pow(1+i,-n)));

	// Equation for interest paid every month.

	interestPaid = loanAmount*i;

	// Equation for Principle paid.

	principlePaid = monthlyPayment-interestPaid;

	// Equation for Loan Balance

	loanBalance = loanAmount-principlePaid;







	cout<<"Month"<<"\t"<<"Payment"<<"\t"<<"Interest Paid"<<"\t"<<"Principle Paid"<<"\t"<<"Loan Balance"<<endl;
	// Beginning of while coding.
	
	do
	{
	

	cout<<month++<<"\t"<<fixed<<setprecision(2)<<monthlyPayment            // Code used to display monthly Payment.
		<<"\t"<<fixed<<setprecision(2)<<interestPaid                       // Code used to display Interest Paid.
	    <<"\t"<<fixed<<setprecision(2)<<principlePaid                      // Code used to display Principle Paid.
		<<"\t"<<fixed<<setprecision(2)<<loanBalance;                       // Code used to display Loan Balance.


	loanBalance = loanBalance-principlePaid;

	interestPaid = loanBalance*i;

	principlePaid = monthlyPayment-interestPaid;
	}

	while (loanBalance>0);

	cin.get ( ); cin.get ( );
	return 0;
}