my program display 0 after run after i enter the loan money, rates and year
thank you for your helps
please point out my errors, i am a beginning C++programer:
#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);
double setannualInterestRate(double);
double setNumberOfYears(int);
double setloanAmount(double);
double getMonthlyPayment(double);
double getTotalPayment(double);
};
double loan::setannualInterestRate(double rates){
return rates;
}
double loan::setNumberOfYears(int years){
return years;
}
double loan::setloanAmount(double amount){
return amount;
}
double loan::getannualInterestRate (double percent) {
return percent;
}
int loan::getNumberOfYears(int years){
return years;
}
double loan::getloanAmount(double money){
return money;
}
double loan::getMonthlyPayment(double payment){
return payment=((1 +percent)* amount)/years;
}
double loan::getTotalPayment(double totalloan){
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;
}
my program display 0 after run after i enter the loan money, rates and year
thank you for your helps
please point out my errors, i am a beginning C++programer:
error: In member function 'double loan::getloanAmount(double)':
44:11: error: a function-definition is not allowed here before '{' token
51:1: error: expected '}' at end of input
int loan::getNumberOfYears(int years){
return years;
}
double loan::getloanAmount(double money){
return money;
int main(){ // error: attempt to define int main(){/*code*/} inside loan::getloanAmount()
loan.L;
L.setloanAmount(40000);
L.setannualInterestRate(5.5);
L.setNumberOfYears(15);
cout<<" your monthly payment is "<<L.getMonthlyPayment()<<".";
cout<< "Your total payment is"<< L.getTotalPayment()<<endl;
}
// error: the closing brace of "getloanAmount()" is missing
Quite many editors do have an indentation command. If they have, it should do systematic indentation.
Hello, I add the } back but there is another error uppear in the program, how to i fix it ??
error: In function 'int main()':
46:5: error: expected unqualified-id before '.' token
47:1: error: 'L' was not declared in this scope
Thank you very much for helping me!!
my program run but the output doesnt seems right :
the output: your monthly payment is -nan.Your total payment is0
I want the output to be monthly loan and total loan ( 40000loan,5.5rates,15yrs)
thank you !!