954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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.

#include <iostream.h> 
#include <math.h> 
#include <cstdlib>
#include <iomanip> //here i am just throwing stuff in to try and fix the "missing function header"
int main( )
 {
   
   double months, amount, rate;		  
   double MonthlyPayment (double amount, double rate, int months);	  
   int GetChoice(void);   
   int option; 
   option = GetChoice();
   
	  {		 
		 cout << "Enter the loan amount: ";
		 cin >> amount;
		 cout << "Enter the interest rate (X.Y): ";
		 cin >> rate;
		 cout << "Enter the length of the loan in months : "; 
		 cin >> months; 
		 cout << "\tYour monthly payment is $ ";			   
	  option = GetChoice(); 
   } 
   return 0; 
}
int GetChoice(void) 
{ 
   int num; 
   cout << endl;   
   cout << "1. Calculate your monthly payment on the loan."
		<< endl << "You will enter the loan amount, Interest rate, and Length of the loan" << endl;  
   cout << "0. Exit the program" << endl; 
   cout << "Press 1 to procede : "; 
   cin >> num; 
   return num; 
} 

{ 

  int (amount * months) / rate = MonthlyPayment; 
  return MonthlyPayment;
}
popo_prince
Newbie Poster
12 posts since Mar 2004
Reputation Points: 14
Solved Threads: 0
 

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()..

meabed
Junior Poster
Team Colleague
139 posts since May 2004
Reputation Points: 55
Solved Threads: 3
 
#include<stdlib.h>
#include<iomanip.h>
Programmer511
Newbie Poster
1 post since Jan 2010
Reputation Points: 4
Solved Threads: 0
 

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.

#include <iostream.h> 
#include <math.h> 
#include <cstdlib>
#include <iomanip> //here i am just throwing stuff in to try and fix the "missing function header"
int main( )
 {
   
   double months, amount, rate;		  
   double MonthlyPayment (double amount, double rate, int months);	  
   int GetChoice(void);   
   int option; 
   option = GetChoice();
   
	  {		 
		 cout << "Enter the loan amount: ";
		 cin >> amount;
		 cout << "Enter the interest rate (X.Y): ";
		 cin >> rate;
		 cout << "Enter the length of the loan in months : "; 
		 cin >> months; 
		 cout << "\tYour monthly payment is $ ";			   
	  option = GetChoice(); 
   } 
   return 0; 
}
int GetChoice(void) 
{ 
   int num; 
   cout << endl;   
   cout << "1. Calculate your monthly payment on the loan."
		<< endl << "You will enter the loan amount, Interest rate, and Length of the loan" << endl;  
   cout << "0. Exit the program" << endl; 
   cout << "Press 1 to procede : "; 
   cin >> num; 
   return num; 
} 

{ 

  int (amount * months) / rate = MonthlyPayment; 
  return MonthlyPayment;
}


after some cleaning now things make sense, at least in my linux system it works fine.

#include <iostream>

using namespace std;

// function prototype
int GetChoice(void);
double MonthlyPayment (double amount, double rate, int months);

int main( )
{
    double months, amount, rate;
    int option;

    option = GetChoice();

    cout << "Enter the loan amount: ";
    cin >> amount;
    cout << "Enter the interest rate (X.Y): ";
    cin >> rate;
    cout << "Enter the length of the loan in months : ";
    cin >> months;
    cout << "\tYour monthly payment is $ ";
    cout << MonthlyPayment(amount, rate, months);

   return 0;
}

int GetChoice(void)
{
   int num;
   cout << endl;
   cout << "1. Calculate your monthly payment on the loan."
		<< endl << "You will enter the loan amount, Interest rate, and Length of the loan" << endl;
   cout << "0. Exit the program" << endl;
   cout << "Press 1 to procede : ";

   cin >> num;

   return num;
}

double MonthlyPayment (double amount, double rate, int months)
{
  int MonthlyPayment = (amount * months) / rate;

  return MonthlyPayment;
}
jBat
Light Poster
26 posts since Aug 2009
Reputation Points: 7
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You