最新版房贷计算器

import com.freeter.model.Calculator;


@RestController
@RequestMapping("app/calculator")
public class calculatorController {


@RequestMapping(value = "houseLoan", produces = "application/json;charset=UTF-8")
public String tradeCalculator(Calculator cal) {
double totalAmountMortgage = 0;
double reimbursemenAmount = 0
double interestPayment = 0
double interestPaymentMonth = 0;
double averageMonthlyAmount = 0;
double interestDurationLoan = 0;
double remainingLoan = 0; 
double totalDueAmount = 0;
JSONObject result = new JSONObject();
int errCode = 1;
String desc = "成功";


if (cal.isLoanType() == true) {

if (cal.isComputeMode() == true) {
totalAmountMortgage = (cal.getArea() * cal.getUnitPrice());
reimbursemenAmount = totalAmountMortgage * cal.getPercentage() * 0.1;


} else {
totalAmountMortgage = cal.getTotalLoan();
reimbursemenAmount = totalAmountMortgage;
}


downPayment = (totalAmountMortgage - reimbursemenAmount);
if (cal.isRepayment() == true) {
averageMonthlyAmount = (reimbursemenAmount * cal.getInterestRates() / 12
* Math.pow(1 + cal.getInterestRates() / 12, +cal.getMonth())
/ (Math.pow(1 + cal.getInterestRates() / 12, cal.getMonth()) - 1));
remainingLoan = reimbursemenAmount;
for (int i = 0; i < cal.getMonth(); i++) {
interestPaymentMonth = remainingLoan * cal.getInterestRates() / 12;
interestDurationLoan = averageMonthlyAmount - interestPaymentMonth;
interestPayment = interestPayment + interestPaymentMonth;// 
remainingLoan = remainingLoan - interestDurationLoan;/
totalDueAmount = reimbursemenAmount + interestPayment;
result.put("totalAmountMortgage", totalAmountMortgage);
result.put("reimbursemenAmount", reimbursemenAmount);/
result.put("interestPayment", interestPayment);// 
result.put("downPayment", downPayment);// 
result.put("averageMonthlyAmount", averageMonthlyAmount);// 


} else {

interestDurationLoan = reimbursemenAmount / cal.getMonth();
double reimbursemenAmount1 = reimbursemenAmount;
for (int i = 0; i < cal.getMonth(); i++) {
interestPaymentMonth = reimbursemenAmount1 * cal.getInterestRates() / 12;
System.out.println("第" + i + "期" + "本金:" + interestDurationLoan + "利息" + interestPaymentMonth
+ " 总额:" + (interestDurationLoan + interestPaymentMonth));
averageMonthlyAmount = interestDurationLoan + interestPaymentMonth;
interestPayment += interestPaymentMonth;
reimbursemenAmount1 -= interestDurationLoan;


}
totalDueAmount = reimbursemenAmount + interestPayment;
result.put("totalAmountMortgage", totalAmountMortgage);
result.put("reimbursemenAmount", reimbursemenAmount);
result.put("interestPayment", interestPayment);
result.put("downPayment", downPayment);
result.put("month", cal.getMonth());
result.put("averageMonthlyAmount", averageMonthlyAmount);
}


} else {
reimbursemenAmount = cal.getTradeMoney() + cal.getReservedFound();
if (cal.isRepayment() == true) {

double tradeMoney = cal.getTradeMoney();
double ReservedFound = cal.getReservedFound();
for (int i = 0; i < cal.getMonth(); i++) {


interestPaymentMonth = ReservedFound * cal.getInterestRates() / 12
+ tradeMoney * cal.getTradeInterestRates() / 12;

interestPayment = interestPayment + interestPaymentMonth;


tradeMoney = tradeMoney - ((cal.getTradeMoney() * cal.getTradeInterestRates() / 12
* Math.pow(1 + cal.getTradeInterestRates() / 12, +cal.getMonth())
/ (Math.pow(1 + cal.getTradeInterestRates() / 12, cal.getMonth()) - 1))
- (tradeMoney * cal.getTradeInterestRates() / 12));
ReservedFound = ReservedFound - ((cal.getReservedFound() * cal.getInterestRates() / 12
* Math.pow(1 + cal.getInterestRates() / 12, +cal.getMonth())
/ (Math.pow(1 + cal.getInterestRates() / 12, cal.getMonth()) - 1))
- (ReservedFound * cal.getInterestRates() / 12));


}
totalDueAmount = reimbursemenAmount + interestPayment;
result.put("reimbursemenAmount", reimbursemenAmount);
result.put("totalDueAmount", totalDueAmount);
result.put("interestPayment", interestPayment);
result.put("month", cal.getMonth());
result.put("averageMonthlyAmount", averageMonthlyAmount);


} else {
reimbursemenAmount = cal.getTradeMoney() + cal.getReservedFound();
interestDurationLoan = reimbursemenAmount / cal.getMonth();
double tradeMoney = cal.getTradeMoney();// 
double ReservedFound = cal.getReservedFound();


tradeMoney = tradeMoney - (cal.getTradeMoney() / cal.getMonth());
ReservedFound = ReservedFound - (cal.getReservedFound() / cal.getMonth());


}
totalDueAmount = reimbursemenAmount + interestPayment;
result.put("reimbursemenAmount", reimbursemenAmount);
result.put("totalDueAmount", totalDueAmount);
result.put("interestPayment", interestPayment);
result.put("averageMonthlyAmount", averageMonthlyAmount);


}
}
result.put("errCode", errCode);
result.put("desc", desc);


return result.toString();
}


}
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值