赋值运算符表达式 + 左手必须是可变的(对于 java 中的整数)

Assigned Operator Expression + left-hand must be variable (for integers in java)

我目前正在设计一个非常基本的利息计算器。由于我对 java 编程语言的了解仍然非常有限,我似乎 运行 遇到了问题。程序中有一行,单个 if 语句不允许我 运行 程序,很容易发现它是唯一的。问题是我总是因为两个原因而停下来,我被告知的一个原因是 "left-hand side of the assignment must be a variable",第二个是 "insert AssignedOperator Expression"。我知道之前可能已经讨论过该主题,但我还没有找到适合我需要的答案,任何帮助都会很棒。

package Unit_1_Review;

import java.util.Scanner;

public class Interest_Calculator_Assignement {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        double initamount, interestrate,interest2,principal,remamount;
    {   int count = 1;

        System.out.print("Please enter the amount you wish to borrow:");
        initamount = input.nextDouble();
        System.out.print("Please enter the borrowing interest rate:");
        interestrate = input.nextDouble();



        while (count <= 10)
        {   
            System.out.println(count);
            count+=1;

            interest2 = ((initamount*interestrate)/12);
            principal = ((initamount*interestrate) - interest2);
            remamount = (initamount - principal);

            *if (count == 2);
                (remamount == initamount);*






        System.out.println("Initial Amount: $" + initamount);
        System.out.println("Interest Rate:" +interestrate);
        System.out.format("Interest:$%.2f", interest2);
        System.out.format("\nPrincipal:$%.2f", principal);
        System.out.format("\nAmount Remaining:$%.2f", remamount);
        System.out.println("        ");


        }

    }

}

}   

A​​t (remamount == initamount); 表示您正在检查 remamount 是否等于 initamount 不使用一个 = 分配其值。添加 { 用于删除分号的 if 条件;在它的条件之后。在 if 条件之前和之后的语法 delete * 以及 int count 之前和代码末尾的额外 { 有问题。