I wrote a program to calculate a loan, the program compiles and works fine, but I get an answer I do not understand. The answer comes out "$1.#J". I am pasting the code here I am using, I am not worried about the code it is a pretty simple set-up and still needs tweaking. I just don't know how to change the answer to display in decimal(ie $1000.00) format Any help is appreciated.

#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
	{
	//Begin text printed to screen on start up section
	cout << " " << endl;// Space out the screen print
	cout << "This program will calculate and display a monthly payment after the Loan Amount,\n"<< endl;
	cout << "Interest Rate, and Term of Loan has beenn input for calculation:\n" << endl;
	//cout << "for 30 years @ 5.75% interest." << endl;
 	cout << uppercase << " " << endl;// Space out the screen print
	//End Text print to screen section, begin Variable Declaration section
double Loan_Amount_Input= 0; //amount of loan variable
	float Interest_Rate_Input= 0; //interest rate
	int Term_of_Loan_Years= 0; // loan term in years
	int Yearly_Interest= 1200;//hard code for 12 * 100 which is used for the yearly interest conversion to decimal
	double Monthly_Irate= Interest_Rate_Input/12;  //annual Interest rate
	int Term_Months= 12 * Term_of_Loan_Years ; //Number of months in loan
	float Monthly_Payment; //A display of users monthly payment
	cout.setf(ios::fixed);//forced fixed format
	cout.precision(2);//sets the number of places after a decimal
	//End Variable Declaration section, begin Input for Variables section
	cout << "Input Loan Amount:\n $";
	cin >> Loan_Amount_Input;
	cout << "Input the Interest Rate:\n %";
	cin >> Interest_Rate_Input;
	cout << "Input the Term of  Loan in Years:\n";
	cin >> Term_of_Loan_Years;
	//End Variable Input, Section begin Calculations Section
	cout.setf(ios::fixed);//forced fixed format
	cout.precision(2);//sets the number of places after a decimal
	Monthly_Payment =Loan_Amount_Input*(Interest_Rate_Input/Yearly_Interest)/(1 - pow((1+Monthly_Irate),-1*Term_Months));
	cout << "\nFor a Loan amout of: \n $"<< Loan_Amount_Input <<"\n and an interest Rate of: \n %"<< Interest_Rate_Input <<"\n The monthly payment will be:\n $"<< Monthly_Payment<<"\n";
	fflush(stdin);
    getchar();  //pause screen
	}
    return 0;
}
This article has been dead for over six months. Start a new discussion instead.