943,600 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 10698
  • C++ RSS
May 8th, 2004
0

missing function header

Expand Post »
i can't get this to run. my math functions at the end have messed up logic.
and the superfluous function headers and such. i don't think the math output is linked to the desired output of the payment.


C++ Syntax (Toggle Plain Text)
  1.  
  2. #include <iostream.h>
  3. #include <math.h>
  4. #include <cstdlib>
  5. #include <iomanip> //here i am just throwing stuff in to try and fix the "missing function header"
  6. int main( )
  7. {
  8.  
  9. double months, amount, rate;
  10. double MonthlyPayment (double amount, double rate, int months);
  11. int GetChoice(void);
  12. int option;
  13. option = GetChoice();
  14.  
  15. {
  16. cout << "Enter the loan amount: ";
  17. cin >> amount;
  18. cout << "Enter the interest rate (X.Y): ";
  19. cin >> rate;
  20. cout << "Enter the length of the loan in months : ";
  21. cin >> months;
  22. cout << "\tYour monthly payment is $ ";
  23. option = GetChoice();
  24. }
  25. return 0;
  26. }
  27. int GetChoice(void)
  28. {
  29. int num;
  30. cout << endl;
  31. cout << "1. Calculate your monthly payment on the loan."
  32. << endl << "You will enter the loan amount, Interest rate, and Length of the loan" << endl;
  33. cout << "0. Exit the program" << endl;
  34. cout << "Press 1 to procede : ";
  35. cin >> num;
  36. return num;
  37. }
  38.  
  39. {
  40.  
  41. int (amount * months) / rate = MonthlyPayment;
  42. return MonthlyPayment;
  43. }
Reputation Points: 14
Solved Threads: 0
Newbie Poster
popo_prince is offline Offline
12 posts
since Mar 2004
May 8th, 2004
0

Re: missing function header

I Don't know what the program about .. and what the last function about ?
maybe u must define the fuction to make it work . then you must declare the variables inside it .coz those variables are declared as local variable in main()..
Team Colleague
Reputation Points: 55
Solved Threads: 3
Junior Poster
meabed is offline Offline
139 posts
since May 2004
Jan 24th, 2010
-3
Re: missing function header
C++ Syntax (Toggle Plain Text)
  1. #include<stdlib.h>
  2. #include<iomanip.h>
Reputation Points: 4
Solved Threads: 0
Newbie Poster
Programmer511 is offline Offline
1 posts
since Jan 2010
Jan 24th, 2010
0
Re: missing function header
i can't get this to run. my math functions at the end have messed up logic.
and the superfluous function headers and such. i don't think the math output is linked to the desired output of the payment.


C++ Syntax (Toggle Plain Text)
  1.  
  2. #include <iostream.h>
  3. #include <math.h>
  4. #include <cstdlib>
  5. #include <iomanip> //here i am just throwing stuff in to try and fix the "missing function header"
  6. int main( )
  7. {
  8.  
  9. double months, amount, rate;
  10. double MonthlyPayment (double amount, double rate, int months);
  11. int GetChoice(void);
  12. int option;
  13. option = GetChoice();
  14.  
  15. {
  16. cout << "Enter the loan amount: ";
  17. cin >> amount;
  18. cout << "Enter the interest rate (X.Y): ";
  19. cin >> rate;
  20. cout << "Enter the length of the loan in months : ";
  21. cin >> months;
  22. cout << "\tYour monthly payment is $ ";
  23. option = GetChoice();
  24. }
  25. return 0;
  26. }
  27. int GetChoice(void)
  28. {
  29. int num;
  30. cout << endl;
  31. cout << "1. Calculate your monthly payment on the loan."
  32. << endl << "You will enter the loan amount, Interest rate, and Length of the loan" << endl;
  33. cout << "0. Exit the program" << endl;
  34. cout << "Press 1 to procede : ";
  35. cin >> num;
  36. return num;
  37. }
  38.  
  39. {
  40.  
  41. int (amount * months) / rate = MonthlyPayment;
  42. return MonthlyPayment;
  43. }

after some cleaning now things make sense, at least in my linux system it works fine.
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. // function prototype
  6. int GetChoice(void);
  7. double MonthlyPayment (double amount, double rate, int months);
  8.  
  9. int main( )
  10. {
  11. double months, amount, rate;
  12. int option;
  13.  
  14. option = GetChoice();
  15.  
  16. cout << "Enter the loan amount: ";
  17. cin >> amount;
  18. cout << "Enter the interest rate (X.Y): ";
  19. cin >> rate;
  20. cout << "Enter the length of the loan in months : ";
  21. cin >> months;
  22. cout << "\tYour monthly payment is $ ";
  23. cout << MonthlyPayment(amount, rate, months);
  24.  
  25. return 0;
  26. }
  27.  
  28. int GetChoice(void)
  29. {
  30. int num;
  31. cout << endl;
  32. cout << "1. Calculate your monthly payment on the loan."
  33. << endl << "You will enter the loan amount, Interest rate, and Length of the loan" << endl;
  34. cout << "0. Exit the program" << endl;
  35. cout << "Press 1 to procede : ";
  36.  
  37. cin >> num;
  38.  
  39. return num;
  40. }
  41.  
  42. double MonthlyPayment (double amount, double rate, int months)
  43. {
  44. int MonthlyPayment = (amount * months) / rate;
  45.  
  46. return MonthlyPayment;
  47. }
Reputation Points: 7
Solved Threads: 3
Light Poster
jBat is offline Offline
26 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Swapping elements
Next Thread in C++ Forum Timeline: break a string into tokens





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC