欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java 根據(jù)貸款年限對應利率計算功能實現(xiàn)解析

 更新時間:2019年10月10日 11:26:58   作者:小龍_T無限  
這篇文章主要介紹了Java 根據(jù)貸款年限對應利率計算功能實現(xiàn)解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

要求

根據(jù)貸款年限對應的不同利率計算月供

實現(xiàn)思路

1.創(chuàng)建一個月供類

2.在該類中,設定判定條件,不同的借款年限對應不同的月供

3.創(chuàng)建一個月供的實例,輸入貸款年限和貸款金額測試

代碼內(nèi)容

月供類

public class MonthPay {
  public int total;//貸款總金額
  public int age; //貸款年限

  public void monthpay() {
    double monthpay;

    if (age<=3){
      monthpay = (6.03/100*total+total)/age;
    }else if(age <=5){
      monthpay = (6.12/100*total+total)/age;
    }else {
      monthpay = (6.39/100*total+total)/age;
    }
    System.out.println("***月供為"+monthpay/12);
  }
}

測試月供類

public class MonthPayTest {
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args) {
    MonthPay monthPay = new MonthPay();

    //選擇貸款金額
    System.out.println("請輸入貸款金額:");
    monthPay.total = sc.nextInt();
    System.out.println("請輸入貸款年限:");
    monthPay.age = sc.nextInt();

    //計算月供
    monthPay.monthpay();
  }
}

運行結果

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論