Loan.java



/** 借金の返済がいかに大変かの計算 */
public class Loan {

 /** 返済開始 */
    public static void main( String[] argv ) {

        int shakkin = 3000000; // 借金の最初の額
        int hensai = 40000;    // 1ヶ月の返済額
        double riritu = 0.01;  // 1ヶ月の利率

        int i;
        for( i=1; true; i++ ) {

            int risoku = (int)(shakkin * riritu);
            shakkin += risoku;
            shakkin -= hensai;

            if( shakkin <= 0 ) break; 
        }
        System.out.println( "It takes " + i/12 +
             " years and " + i%12 + " months...." );
    }
}