//用户输入年利率、年数及贷款额度,通过计算显示月支付额度和总共支付额度。
import java.util.Scanner;
public class Study{
public static void main(String[] args) {
Scanner a=new Scanner(System.in);
System.out.println("请输入年利率,如7.25");
double annualInterestrate=a.nextDouble();//输入带百分号的年利率
double monthlyIntersestRate=annualInterestrate/1200;//获得月利率
System.out.println("请输入一个整数作为年数");
int year=a.nextInt();
System.out.println("请输入贷款额度,如120000.95");
double money=a.nextDouble();//输入贷款额度
double monthlyPayment=money*monthlyIntersestRate/(1-1/Math.pow(1+ monthlyIntersestRate,year*12));//计算月支付额度
double totalPayment=monthlyPayment*year*12;//计算总共支付额度
System.out.println("月支付额度为:"+(int)(monthlyPayment*100)/100.0);
System.out.println("总共支付额度为:"+(int)(totalPayment*100)/100.0);
//输出结果
}
}