贷款利息计算
计算 贷款
2023-09-14 09:08:27 时间
package test; import java.net.ServerSocket; public class Profit { public Profit() { } static int loadYears = 25; public static void main(String[] args) { //gongjijin: 0.0325d //shang dai: 0.0515d dengBenJin(175, 0.0515d*0.88); double sum=0; // sum= dengE(120, 0.0325d); // sum+=dengE(55,0.0515d*0.88); // System.out.println("sum:"+sum); } static double dengE(double load, double loadInterest) { // final value load*=10000 ; double monthProfit = loadInterest / 12; double monthPay = load * monthProfit * Math.pow(1 + monthProfit, loadYears * 12) / (Math.pow(1 + monthProfit, loadYears * 12) - 1); int startMonth = 0;// the month started to pay back. 0 means start from // Jan. int startYear = 14; // the year start to pay back. 14 means start from // 2014. double sum = 0; double remainLoad = load; for (int i = startMonth; i < loadYears * 12 + startMonth; i++) { double interest = remainLoad * monthProfit; double monthBenjin = (monthPay - interest); remainLoad -= monthBenjin; sum += monthPay; int theMonth = i % 12; int theYear = i / 12; if (theMonth == 0) System.out.println(2000 + (theYear + startYear) + "年"); // System.out.println("\t" + (theMonth + 1) + "月\t\t" + monthPay + // "元\t" + "\t 本金:" +monthBenjin + "\t 利息:" + interest); System.out.println("\t" + (theMonth + 1) + "月\t\t" + convert(monthPay) + "元\t" + "\t 本金:" + convert(monthBenjin) + "\t 利息:" + convert(interest)); } System.out.println(" 总共付款 " + "\t\t" + convert(sum) + "元\n利息:\t\t " + convert(sum - load) + "元"); // System.out.println(" 总共付款" + "\t\t" + monthPay*12*years + "元\n利息:\t\t " + (monthPay*12*years - base) + "元"); return sum - load; } private static double dengBenJin(double load, double loadInterest) { // final value load*=10000 ; double monthProfit = loadInterest / 12; double monthBenjin = load / (loadYears * 12); int startMonth = 0;// the month started to pay back. 0 means start from // Jan. int startYear = 14; // the year start to pay back. 14 means start from // 2014. double sum = 0; for (int i = startMonth; i < loadYears * 12 + startMonth; i++) { double interest = (load - monthBenjin * (i - startMonth)) * monthProfit; double monthPay = monthBenjin + interest; sum += monthPay; int theMonth = i % 12; int theYear = i / 12; if (theMonth == 0) System.out.println(2000 + (theYear + startYear) + "年"); System.out.println("\t" + (theMonth + 1) + "月\t\t" + convert(monthPay) + "元\t" + "\t 本金:" + convert(monthBenjin) + "\t 利息:" + convert(interest)); } System.out.println(" 总共付款 " + "\t\t" + sum + "元\n利息:\t\t " + (sum - load) + "元"); return sum - load; } static double convert(double value) { long l1 = Math.round(value * 100); // 四舍五入 double ret = l1 / 100.0; // 注意:使用 100.0 而不是 100 return ret; } }
相关文章
- 考研竞赛每日一练 day 3 一道定积分定义计算问题
- hive、maxcompute计算当月累计、当年累计值示例
- 在re:Invent 2022大会上,我们看到了云计算的未来
- 【计算理论】计算复杂性 ( 多项式等价 | P 类 | 丘奇-图灵论题延伸 )
- 【计算理论】计算理论总结 ( 泵引理 Pumping 证明 ) ★★
- Nature子刊 | 谭济民、夏波等提出基因组构象预测模型及高通量计算遗传筛选方法
- javascript计算两个日期之间相差多少天详解编程语言
- Oracle数据库查询:计算总记录数(oracle查总数)
- 计算Oracle日期间隔:天数之差(oracle日期天数差)
- 用Linux和C进行程序编写,如何计算运行时间?(linuxc运行时间)
- Oracle中计算平均值的AVG函数(oracle中的avg)
- js获取计算后的样式写法及注意事项
- python计算最小优先级队列代码分享