美文网首页
贷款界面实践

贷款界面实践

作者: 客观开发者 | 来源:发表于2016-11-21 14:35 被阅读46次

写了一个关于利率贷款的界面和其他的算法,算法抄的别人的。

界面dialog 和pop两种显示方式。

demo目前没有上传。

算法 可以使用一下

/**

* 商业和公积金贷款

* @param ze  贷款总额

* @param nx  年限

* @param rate 利率

*/

public void cal(double ze, double nx, double rate) {

double zem = (ze * rate / 12 * Math.pow((1 + rate / 12), nx))

/ (Math.pow((1 + rate / 12), nx) - 1);

double amount = zem * nx;

double rateAmount = amount - ze;

BigDecimal zemvalue = new BigDecimal(zem);

double zemval = zemvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal amountvalue = new BigDecimal(amount);

double amountval = amountvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal rateAmountvalue = new BigDecimal(rateAmount);

double rateAmountval = rateAmountvalue.setScale(2,

BigDecimal.ROUND_HALF_UP).doubleValue();

double benjinm = ze / nx;

double lixim = ze * (rate / 12);

double diff = benjinm * (rate / 12);

double huankuanm = benjinm + lixim;

double zuihoukuan = diff + benjinm;

double av = (huankuanm + zuihoukuan) / 2;

double zong = av * nx;

double zongli = zong - ze;

BigDecimal huankuanmvalue = new BigDecimal(huankuanm);

double huankuanmval = huankuanmvalue.setScale(2,

BigDecimal.ROUND_HALF_UP).doubleValue();

BigDecimal diffvalue = new BigDecimal(diff);

double diffmval = diffvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal zongvalue = new BigDecimal(zong);

double zongval = zongvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal zonglivalue = new BigDecimal(zongli);

double zonglival = zonglivalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

/*等额本息*/

//        am10.setText(ze + "元"); 总额

//        am11.setText(nx + "月"); 月份

//        am12.setText(zemval + "元"); 月供

//        am13.setText(rateAmountval + "元"); 合计利息

//        am14.setText(amountval + "元"); 本息合计

Logger.d("等额本息" + ze + "年限" + (int) (nx / 12) + "dd" + zemval + "合计利息" + rateAmountval + "dd" + amountval);

/*等额本金*/

//        am20.setText(ze + "元");

//        am21.setText(nx + "月");

//        am22.setText("首月" + huankuanmval + ",月减" + diffmval);

//        am23.setText(zonglival + "元");合计利息

//        am24.setText(zongval + "元"); 本息合计

Logger.d("等额本金" + ze + "nx" + nx / 12 + "zongli" + zonglival + "zongval" + zongval + "首月" + huankuanmval + ",月减" + diffmval);

String title = "等额本息还款";

String nina = removeDian(daiqixian);

String zed = getDecimalFormat(ze);

String amountvald = getDecimalFormat(amountval);

String zongvald = getDecimalFormat(zongval);

String rateAmountvald = getDecimalFormat(rateAmountval);

String zonglivald = getDecimalFormat(zonglival);

if (delxoj == 1) {

title = "等额本息还款";

bottomDialog.title(title).hideCancel().addResult(delxoj, zed, nina + "年", amountvald, zemval, zemval, rateAmountvald).show();

} else {

title = "等额本金还款";

bottomDialog.title(title).hideCancel().addResult(delxoj, zed, nina + "年", zongvald, huankuanmval, diffmval, zonglivald).show();

}

}

/**

* 混合 贷款

*

* @param ze  公积金总额

* @param nx  年限

* @param rate 公积金利率

* @param ze1  商业总额

* @param rate1 商业利率

*/

public void cal(double ze, double nx, double rate, double ze1, double rate1) {

double zem = (ze * rate / 12 * Math.pow((1 + rate / 12), nx))

/ (Math.pow((1 + rate / 12), nx) - 1);

double amount = zem * nx;

double rateAmount = amount - ze;

double zem1 = (ze1 * rate1 / 12 * Math.pow((1 + rate1 / 12), nx))

/ (Math.pow((1 + rate1 / 12), nx) - 1);

double amount1 = zem1 * nx;

double rateAmount1 = amount1 - ze1;

BigDecimal zemvalue = new BigDecimal(zem + zem1);

double zemval = zemvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal amountvalue = new BigDecimal(amount + amount1);

double amountval = amountvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal rateAmountvalue = new BigDecimal(rateAmount + rateAmount1);

double rateAmountval = rateAmountvalue.setScale(2,

BigDecimal.ROUND_HALF_UP).doubleValue();

double benjinm = ze / nx;

double lixim = ze * (rate / 12);

double diff = benjinm * (rate / 12);

double huankuanm = benjinm + lixim;

double zuihoukuan = diff + benjinm;

double av = (huankuanm + zuihoukuan) / 2;

double zong = av * nx;

double zongli = zong - ze;

double benjinm1 = ze1 / nx;

double lixim1 = ze1 * (rate1 / 12);

double diff1 = benjinm1 * (rate1 / 12);

double huankuanm1 = benjinm1 + lixim1;

double zuihoukuan1 = diff1 + benjinm1;

double av1 = (huankuanm1 + zuihoukuan1) / 2;

double zong1 = av1 * nx;

double zongli1 = zong1 - ze1;

BigDecimal huankuanmvalue = new BigDecimal(huankuanm + huankuanm1);

double huankuanmval = huankuanmvalue.setScale(2,

BigDecimal.ROUND_HALF_UP).doubleValue();

BigDecimal diffvalue = new BigDecimal(diff + diff1);

double diffmval = diffvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal zongvalue = new BigDecimal(zong + zong1);

double zongval = zongvalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

BigDecimal zonglivalue = new BigDecimal(zongli + zongli1);

double zonglival = zonglivalue.setScale(2, BigDecimal.ROUND_HALF_UP)

.doubleValue();

/*等额本息*/

//        am10.setText((ze + ze1) + "元");

//        am11.setText(nx + "月");

//        am12.setText(zemval + "元");

//        am13.setText(rateAmountval + "元");

//        am14.setText(amountval + "元");

/*等额本金*/

//        am20.setText((ze + ze1) + "元");

//        am21.setText(nx + "月");

//        am22.setText("首月" + huankuanmval + ",月减" + diffmval);

//        am23.setText(zonglival + "元");

//        am24.setText(zongval + "元");

Logger.d((ze + ze1) + "每月" + nx + zemval + "元" + rateAmountval + "元" + amountval + "元");

Logger.d((ze + ze1) + "每月" + nx + "首月" + huankuanmval + ",月减" + diffmval + "元" + zonglival + "元" + zongval + "元");

String title = "等额本息还款";

String nina = removeDian(daiqixian);

String zed = getDecimalFormat(ze + ze1);

String amountvald = getDecimalFormat(amountval);

String zongvald = getDecimalFormat(zongval);

String rateAmountvald = getDecimalFormat(rateAmountval);

String zonglivald = getDecimalFormat(zonglival);

if (delxoj == 1) {

title = "等额本息还款";

bottomDialog.title(title).hideCancel().addResult(delxoj, zed, nina + "年", amountvald, zemval, zemval, rateAmountvald).show();

} else {

title = "等额本金还款";

bottomDialog.title(title).hideCancel().addResult(delxoj, zed, nina + "年", zongvald, huankuanmval, diffmval, zonglivald).show();

}

}

目前还不会排版,还是小学生,希望可以帮你。


相关文章

网友评论

      本文标题:贷款界面实践

      本文链接:https://www.haomeiwen.com/subject/ysczettx.html