⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debt.cpp

📁 用于计算住房按揭贷款 输入:贷款金额、按揭期(月)数及银行利率(五年内和五年外) 输出:等额本息月供、贷款利息总额、剩余本金及支付利息金额
💻 CPP
字号:
#include "Debt.h"
#include "AccDebt.h"

void Debt::GetR(double _R5, double _R30)
{
	this->R5=_R5;
	this->R30=_R30;
}

double Debt::GetN(double _n)
{
	this->N=_n;
	if(N<=60) R=R5;
	else R=R30;
	return N;
}

double Debt::GetT(double _t)
{
	this->T=_t;
	return T;
}

double Debt::GetP(double _p)
{
	this->P=_p;
	return P;
}

double Debt::CalP()
{
	this->P=T*AccPower(R,N)/AccSumPower(R,N);
	return P;
}

double Debt::CalIncrement()
{
	this->Increment=N*P-T;
	return Increment;
}

void Debt::CalPayTable()
{
	int i=0,j=0;

	for(i=0;i<30;i++)
	{
		j=(i+1)*12;
		if(i<5)
	this->Table[i]=AccPower(R5,j)/AccSumPower(R5,j)*10000;
		else
    this->Table[i]=AccPower(R30,j)/AccSumPower(R30,j)*10000;
	}
}

void Debt::ShowInfo()
{
	cout<<"********* The total of debt (unit: Yuan) **********************"<<endl;
	cout<<"You totally owe our bank: "<<T<<" Yuan."<<endl;
	cout<<"********* The mount of periodics (unit: month) ****************"<<endl;
	cout<<"You should pay off all the debt in: "<<N<<" Months."<<endl;
	cout<<"********* Pay for each month (unit: Yuan) *********************"<<endl;
	cout<<"Each month you should pay: "<<P<<" Yuan."<<endl;
	cout<<"********* debt and increment (unit: Yuan) *********************"<<endl;
	cout<<"You totally pay our bank: "<<T+Increment<<" Yuan."<<endl;
	cout<<"********* Increment (unit: Yuan) ******************************"<<endl;
	cout<<"The total Increment is: "<<Increment<<" Yuan."<<endl;
	cout<<"********* The below is a paytable with basis 10,000 Yuan ******"<<endl;
	cout<<"YEARS     "<<"pay-rate      "<<endl<<endl;
	for(int i=0;i<30;i++)
	{
	cout.width(3);
	cout<<i+1;
	cout.width(16);
	cout.precision(8);
	cout<<Table[i]<<endl;
	}
	cout<<"***************************************************************"<<endl;
}

double Debt::RemainAft(int nMonth)
{
	this->Remain=T*AccPower(this->R,nMonth)-P*AccSumPower(R,nMonth);
	return Remain;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -