0

我正在尝试为任何类型的固定利率分期贷款(包括抵押贷款)制作计算器。这是我用于基本计算器的以下脚本:

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));

我想为额外的每月付款添加一个文本编辑;但是,我不知道如何计算这个,或者调整我的 editMnthlypmt 方程。

有什么建议么?

4

1 回答 1

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;
于 2013-11-02T21:12:22.567 回答