文件名称:LOAN面向对向类程序
文件大小:3KB
文件格式:ZIP
更新时间:2018-12-03 06:19:38
C++
面向对象类的一个列子 Loan::Loan(double r,int y,double a){
annualInterestRate=r;
numberOfYears=y;
loanAmount=a;
}
Loan::Loan(const Loan& loan){
annualInterestRate = loan.annualInterestRate;
numberOfYears = loan.numberOfYears;
loanAmount = loan.loanAmount;
}
double Loan::getAnnualInterestRate(){
return annualInterestRate;
}
int Loan::getNumberOfYears(){
return numberOfYears;
}
double Loan::getLoanAmount(){
return loanAmount;
}
void Loan::setAnnualInterestRate(double rate){
annualInterestRate=rate;
}
void Loan::setNumberOfYears(int years){
numberOfYears = years;
}
void Loan::setLoanAmount(double amount){
loanAmount = amount;
}
double Loan::getTotalPayment(){
return annualInterestRate*loanAmount*numberOfYears+loanAmount;
}
double Loan::getMounthlyPayment(){
return getTotalPayment()/getNumberOfYears()/12;
}
void Loan::display( )
{
cout<<"----计算列表----"<
【文件预览】:
Loan
----loanmain.cpp(278B)
----loan.h(712B)
----main.cpp(2KB)