1.月还款计算,代码如下:(自己用的IDEA编辑器,下面是自己写的代码~)
package com.lanlanla.demo;
import java.util.Scanner;
/**
* @Author: lilanlan
* @Description: Math.pow(3,4)=81
* @Date: 2019-09-11 19:41
*/
public class MonthlyRepayment {
public static void main(String []args)
{
double intereStrate;
double totalLoans;
int years;
System.out.println("请以依次入:利率、贷款总额、还款年数/n");//println只能带一个基本数据类的参数,并换行
Scanner input=new Scanner(System.in);
intereStrate=input.nextDouble();
totalLoans=input.nextDouble();
years=input.nextInt();
double monthlyRepayment=(totalLoans*intereStrate)/(1-(1/Math.pow(1+intereStrate,years*12)));
System.out.printf("MonthlyRepayment =%.2f",monthlyRepayment);//printf用于所有格式的输出
}
}
运行调试结果如下: