我正在尝试为任何类型的固定利率分期贷款(包括抵押贷款)制作计算器。以下是基本计算器的以下脚本:
EditText myEdit = (EditText) findViewById(R.id.editBalance);
String myEditValue = myEdit.getText().toString();
double loanAmount = Double.parseDouble(myEditValue);
EditText myEdit2 = (EditText) findViewById(R.id.editRate);
String myEditValue2 = myEdit2.getText().toString();
double interestRate = Double.parseDouble(myEditValue2);
EditText myEdit3 = (EditText) findViewById(R.id.editTerm);
String myEditValue3 = myEdit3.getText().toString();
Double loanPeriod = Double.parseDouble(myEditValue3);
double r = interestRate/1200;
double r1 = Math.pow(r+1,loanPeriod);
double editMnthlypmt = (double) ((r+(r/(r1-1))) * loanAmount);
TextView textMnthlypmt = (TextView)findViewById(R.id.textMntlypmt);
textMnthlypmt.setText("" + String.valueOf(editMnthlypmt));
我想为每月额外付款添加一个textEdit;但是,我不知道如何计算这个,或者调整我的等式为editMnthlypmt。
有什么建议吗?
答案 0 :(得分:0)
这个等式已经完成,效果很好。
case R.id.calculate2:
if (nicknameStr.length() > 0 && origBalStr.length() > 0 && myAPRStr.length() > 0 && origTermStr.length() > 0 && myPmtStr.length() > 0)
{
double originalBalance = Double.parseDouble(origBalStr);
double interestRate = Double.parseDouble(myAPRStr);
double originalTerm = Double.parseDouble(origTermStr);
double remainingBalance = Double.parseDouble(strOutBal);
double r = interestRate/1200;
double r1 = Math.pow(r+1,originalTerm);
double minPmt = (double) ((r+(r/(r1-1))) * originalBalance);
DecimalFormat df = new DecimalFormat("#.##");
minPmt = Double.valueOf(df.format(minPmt));
dispMinPmt.setText("" + String.valueOf(minPmt));
double additionalPayment = Double.parseDouble(myPmtStr);
double newPmt = minPmt + additionalPayment;
dispNewPmt.setText("" + newPmt);
double periodRate = r;
double remTop = ((-1*Math.log(1-(periodRate) * (remainingBalance / newPmt))));
double remBottom = (Math.log(1 + periodRate));
double nRemaining = remTop / remBottom;
double initialInt = (minPmt * nRemaining) - remainingBalance;
double newInt = (newPmt * nRemaining) - remainingBalance;
double amountSaved = initialInt - newInt;
}
else
{
Toast.makeText(getApplicationContext(), "Please complete all above fields", Toast.LENGTH_SHORT).show();
}
break;