programing error

double percent;
int years;
public:
double annualInterestRate(double);
int NumberOfYears(int);
double loanAmount(double);
double monthlypayment;
double getannualInterestRate(double);
int getNumberOfYears(int);
double getloanAmount(double);
void setannualInterestRate(double);
void setNumberOfYears(int);
void setloanAmount(double);
double getMonthlyPayment;
double getTotalPayment;
};
void loan::setannualInterestRate(double AIR){
rates=AIR;
}
void loan::setNumberOfYears(int N){
years=N;
}
void loan::setloanAmount(double IA){
amount=IA;
}
double loan::getannualInterestRate( double percent) {
return (annualInterestRate=percent);
}
int loan::getNumberOfYears(int years){
return NumberOfYears=years;
}
double loan::getloanAmount(double money){
return loanAmount=money;
}
double loan::getMonthlyPayment(double X){
return payment=(loanAmount * annualInterestRate/12 * x ) / (x-1);
}
double loan::getTotalPayment(){
return totalloan=payment*years;
}
int main()
{
int NumberOfYears;
int years;
double annualInterestRate;
double loanAmount;
double payment;
double totalloan;
cout<<" Enter the loan Amount";
cin>>loanAmount;
cout<<" Enter the annuak interest rate of the loan:";
cin>>annualInterestRate;
cout<<" Enter the number of years for the loan";
cin>>years;
cout<<" your monthly payment is "<<payment<<".";
cout<<" your total loan is"<<totalloan;

i try to make the program work but it uppear the following error, i am a beginner of C++ Thank you very much!!
64:5: error: stray '\357' in program
64:5: error: stray '\274' in program
64:5: error: stray '\233' in program
66:5: error: stray '\357' in program
66:5: error: stray '\274' in program
66:5: error: stray '\233' in program
67:1: error: stray '\357' in program
67:1: error: stray '\275' in program
67:1: error: stray '\235' in program
In member function 'double loan::getannualInterestRate(double)':
37:31: error: invalid use of member function (did you forget the '()' ?)
In member function 'int loan::getNumberOfYears(int)':
40:25: error: invalid use of member function (did you forget the '()' ?)
In member function 'double loan::getloanAmount(double)':
43:22: error: invalid use of member function (did you forget the '()' ?)
At global scope:
45:40: error: no 'double loan::getMonthlyPayment(double)' member function declared in class 'loan'
48:30: error: no 'double loan::getTotalPayment()' member function declared in class 'loan'
In function 'int main()':
65:5: error: expected ';' before 'cout'
66:34: error: expected ';' at end of input
53:9: warning: unused variable 'NumberOfYears' [-Wunused-variable]
57:12: warning: unused variable 'payment' [-Wunused-variable]
66:34: error: expected '}' at end of input
In member function 'double loan::getannualInterestRate(double)':
38:1: warning: control reaches end of non-void function [-Wreturn-type]
In member function 'int loan::getNumberOfYears(int)':
41:1: warning: control reaches end of non-void function [-Wreturn-type]
In member function 'double loan::getloanAmount(double)':
44:1: warning: control reaches end of non-void function [-Wreturn-type]
closed account (1vD3vCM9)
Please. Put the code in a code segment like this:
 
int OK;


And look at the error. It explains what is the problem very clearly.
#include<iostream>
using namespace std;
#include <iomanip>
#include <cmath>
class loan{
private:
double rates;
double amount;
double payment;
double totalloan;
double percent;
int years;
public:
double annualInterestRate(double);
int NumberOfYears(int);
double loanAmount(double);
double monthlypayment;
double getannualInterestRate(double);
int getNumberOfYears(int);
double getloanAmount(double);
void setannualInterestRate(double);
void setNumberOfYears(int);
void setloanAmount(double);
double getMonthlyPayment;
double getTotalPayment;
};
void loan::setannualInterestRate(double AIR){
rates=AIR;
}
void loan::setNumberOfYears(int N){
years=N;
}
void loan::setloanAmount(double IA){
amount=IA;
}
double loan::getannualInterestRate (double percent) {
return percent;
return 0;
}
int loan::getNumberOfYears(int years){
return years;
return 0;
}
double loan::getloanAmount(double money){
return money;
return 0;
}
double loan::getMonthlyPayment(double payment){
return payment=((1 +percent)* money)/years
}
double loan::getTotalPayment(){
return totalloan=payment*years;
}
int main()
{
int years;
double annualInterestRate;
double loanAmount;
double payment;
double totalloan;
cout<<" Enter the loan Amount";
cin>>loanAmount;
cout<<" Enter the annuak interest rate of the loan:";
cin>>annualInterestRate;
cout<<" Enter the number of years for the loan";
cin>>years;
cout<<" your monthly payment is "<<payment<<".";
cout<< "Your total payment is"<< totalloan<<endl;
}

i try to fixed everythingg i can but there is still two error in line

double loan::getMonthlyPayment(double payment){
return payment=((1 +percent)* money)/years
}
double loan::getTotalPayment(){
return totalloan=payment*years;
}

error:error: no 'double loan::getMonthlyPayment(double)' member function declared in class 'loan'
51:30: error: no 'double loan::getTotalPayment()' member function declared in class 'loan'
As oren drobitsky said, please use code tags. Edit your posts, highlight the code and then click the <> button to the right of the edit window. This will cause the code to display with syntax highlighted and line numbers. It makes it much easier to refer to the code.

error:error: no 'double loan::getMonthlyPayment(double)' member function declared in class 'loan'

You define a function called loan::getMonthlyPayment(), but in the class declaration at the top of the program, getMonthlyPayment is declared as a member variable, not a method:
double getMonthlyPayment;

double getMonthlyPayment;[/code], but this isn't a function.
51:30: error: no 'double loan::getTotalPayment()' member function declared in class 'loan'

This is the same problem. getTotalPayment is declared as a variable, not a function.
Topic archived. No new replies allowed.