1
錯誤C2143:語法錯誤:缺少';' 'constant'之前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;
'monthlyI =(平衡*利息)12;'最有可能在那裏。 –
編譯器應該告訴你錯誤在哪一行。你看過那條線嗎?它是否包含像「(平衡*興趣)12」這樣的虛假表達? –
它說「語法錯誤:缺少';'...」。所以,* syntax *有問題。正如其他人所說*(平衡*興趣)12 * - 錯誤(語法上)。 – SChepurin