Visual C ++错误C2143不知道丢失了什么

时间:2013-10-23 08:41:08

标签: c++ visual-c++

错误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;

1 个答案:

答案 0 :(得分:2)

此行语法无效

monthlyI = (balance*Interest)12;
//                          ^^^
你可能意味着:

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