模拟一个简单的购房商贷月供计算器,按照总利息和每月还款金额

代码如下:

public class Loan {
    /*
     *   模拟一个简单的购房商贷月供计算器,按照总利息和每月还款金额
     *   22点24分
     *   奈何桥
     */
    public double loan(double loan,int yearchoice){
        double money = 0;
        if (yearchoice == 1){
            money=(loan+loan*0.0603)/36;
        }else if (yearchoice ==2){
            money=(loan+loan*0.0612)/60;
        }else {
            money=(loan+loan*0.0639)/240;
        }
        return money;
    }
}

import java.util.Scanner;

public class Testioan {
    public static void main(String[] args) {
        Loan l = new Loan();
        Scanner input = new Scanner(System.in);
        System.out.println("请输入贷款金额");
        double Loan=input.nextDouble();
        System.out.println("请输入贷款年限:1.3年(36个月)3.20年(240给月):");
        int yc = input.nextInt();
        System.out.println("\n***月供为:" +l.Loan(Loan,yc));
    }
}

相关推荐
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页