1

错误 C2143:语法错误:缺少“;” 在“常数”之前

我不知道是怎么回事。我像往常一样写作,这是我第一次遇到这个错误。我还是新手,还在学习,所以我可能会错过一些明显的东西,但我不知道这意味着什么,这个程序对我来说看起来是正确的。我在哪里缺少分号?它也是我唯一的错误。

double LoanA, Interest, monthlyP, balance, totalInterest, monthlyI, LastPay;
int monthCount;

cout << "Enter the loan ammount: $";
cin >> LoanA;
cout << endl << "Enter annual interest rate in percentage: ";
cin >> Interest;
cout << endl << "Enter monthly payment: $";
cin >> monthlyP;
cout << endl;

monthCount = 1;
balance = LoanA;
totalInterest = 0;
monthlyI = 0;

Interest = Interest/100;

while (balance > 0)
    {

        monthlyI = (balance*Interest)12;
        balance = balance + monthlyI;
        balance = balance - monthlyP;
        totalInterest = totalInterest + monthlyI;
        monthCount++;
        cout << "month: " << monthCount << " Interest paid: " << monthlyI << " Remaining debt: " << balance << endl;

    }

LastPay = (balance+monthlyP)+monthlyI;

cout << "Total number of payments = " << monthCount << endl;
cout << "Total amount of interest paid = " << totalInterest << endl;
cout << "The last payment = " << LastPay << endl;
4

1 回答 1

2

此行语法无效

monthlyI = (balance*Interest)12;
//                          ^^^

你可能的意思是:

monthlyI = (balance*Interest) / 12;
//                           ^^^^
于 2013-10-23T08:42:27.857 回答