我正在尝试解决一个问题,即我尝试让我的循环在每个循环之后取一个新值。该程序假设我的利息支付罚款,本金支付当前余额,这样做我的利息假设每次循环时都会减少,但它只会循环第一个答案超过
这是第一个答案是正确的输出,但其他三个是
    Enter Loan Amount:500
    Enter Annual Interest:50
    Total payment:4
    Enter Loan Length :1
    Interest PaymentPrincipal PaymentCurrent Balance
    Interest Payment Principal Payment Current Balance 62.5
    62.5
    62.5
    62.5
它应该是第一次付款后余额的 12.5%。
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        //variabled decleared
        double rate;
        double payment;
        int amt = 1;
       //input
       System.out.print("Enter Loan Amount:");
        double principal = input.nextDouble();
        System.out.print("Enter Annual Interest:");
        double interest = input.nextDouble();
        System.out.print("Total payment:");//12=monthly,4= quartely,2=semi-annually and 1=annually
        double period = input.nextDouble();
        System.out.print("Enter Loan Length :");
        int length = input.nextInt();
        //proces
        rate = interest / 100;
        double period_rate = rate / period;
          double n = period * length;
        payment = (principal*Math.pow((1+period_rate),n))/n;
        System.out.printf("\n"+"Interest Payment"+"     Principal Payment       "+"         Current Balance     ");
        for(int i=1; i<=n; i++){
        double principal_payment=0;
        double current_balance;
        double payment_interest;
        current_balance=(principal-principal_payment);
         payment_interest=(principal*period_rate);
        principal_payment=(payment-payment_interest);
        principal=current_balance;
         System.out.println(payment_interest+"");
         }