Java tutorial
//package com.java2s; import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static int getFirstMonthPay(int amount, double monthRate, int totalMonth) { double firstMonthPay = (amount / totalMonth) + amount * monthRate; return BigDecimal.valueOf(firstMonthPay).setScale(2, RoundingMode.HALF_UP).intValue(); } }