| | |
What does #J stand for?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 1
Reputation:
Solved Threads: 0
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.
C++ Syntax (Toggle Plain Text)
#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; }
Last edited by Ancient Dragon; Apr 19th, 2008 at 1:14 pm. Reason: add code tags
This tells you to use code tags - http://www.daniweb.com/forums/forum2.html
So does this - http://www.daniweb.com/forums/forum8.html
Wait for it, wait for it - http://www.daniweb.com/forums/announcement8-3.html
You're not going to believe this - http://www.daniweb.com/forums/thread78223.html
And not forgetting the watermark at the back of the edit window.
So does this - http://www.daniweb.com/forums/forum8.html
Wait for it, wait for it - http://www.daniweb.com/forums/announcement8-3.html
You're not going to believe this - http://www.daniweb.com/forums/thread78223.html
And not forgetting the watermark at the back of the edit window.
line 36 of your program: Please read this thread how to flush the input stream because fflush() is only for output streams.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Monitor turn off after stand-by (Monitors, Displays and Video Cards)
- How to cancel the Stand By button in win xp sp2 ? (Windows NT / 2000 / XP)
- Restarting after going to stand by (Troubleshooting Dead Machines)
- Missing Graphics! Monitor Stand-by.. (Windows NT / 2000 / XP)
- How I can Find "Stand by" in Window2K (Windows NT / 2000 / XP)
- What does EB stand for on a PIII processor? (Motherboards, CPUs and RAM)
- Error message when executing stand-alone applications(apps with no dll files etc.) (Windows NT / 2000 / XP)
- Stand and Hibernation Issue (Windows NT / 2000 / XP)
- "Preparing to stand by..." (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Conversion from variables to arrays
- Next Thread: reading the serial port
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






