What does #J stand for?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 1
Reputation: BOTnPAID4 is an unknown quantity at this point 
Solved Threads: 0
BOTnPAID4 BOTnPAID4 is offline Offline
Newbie Poster

What does #J stand for?

 
0
  #1
Apr 19th, 2008
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.

  1. #include <cmath>
  2. #include <iostream>
  3. #include <iomanip>
  4. using namespace std;
  5. int main ()
  6. {
  7. {
  8. //Begin text printed to screen on start up section
  9. cout << " " << endl;// Space out the screen print
  10. cout << "This program will calculate and display a monthly payment after the Loan Amount,\n"<< endl;
  11. cout << "Interest Rate, and Term of Loan has beenn input for calculation:\n" << endl;
  12. //cout << "for 30 years @ 5.75% interest." << endl;
  13. cout << uppercase << " " << endl;// Space out the screen print
  14. //End Text print to screen section, begin Variable Declaration section
  15. double Loan_Amount_Input= 0; //amount of loan variable
  16. float Interest_Rate_Input= 0; //interest rate
  17. int Term_of_Loan_Years= 0; // loan term in years
  18. int Yearly_Interest= 1200;//hard code for 12 * 100 which is used for the yearly interest conversion to decimal
  19. double Monthly_Irate= Interest_Rate_Input/12; //annual Interest rate
  20. int Term_Months= 12 * Term_of_Loan_Years ; //Number of months in loan
  21. float Monthly_Payment; //A display of users monthly payment
  22. cout.setf(ios::fixed);//forced fixed format
  23. cout.precision(2);//sets the number of places after a decimal
  24. //End Variable Declaration section, begin Input for Variables section
  25. cout << "Input Loan Amount:\n $";
  26. cin >> Loan_Amount_Input;
  27. cout << "Input the Interest Rate:\n %";
  28. cin >> Interest_Rate_Input;
  29. cout << "Input the Term of Loan in Years:\n";
  30. cin >> Term_of_Loan_Years;
  31. //End Variable Input, Section begin Calculations Section
  32. cout.setf(ios::fixed);//forced fixed format
  33. cout.precision(2);//sets the number of places after a decimal
  34. Monthly_Payment =Loan_Amount_Input*(Interest_Rate_Input/Yearly_Interest)/(1 - pow((1+Monthly_Irate),-1*Term_Months));
  35. 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";
  36. fflush(stdin);
  37. getchar(); //pause screen
  38. }
  39. return 0;
  40. }
Last edited by Ancient Dragon; Apr 19th, 2008 at 1:14 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: What does #J stand for?

 
1
  #2
Apr 19th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,585
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1486
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: What does #J stand for?

 
0
  #3
Apr 19th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC