我收到一條錯誤消息,指出「期望的主表達式」;'令牌「,它突出顯示了我的百分比公式。我試圖重新排列我的代碼,但似乎問題不在其中。';'之前的C++期望primary-expression令牌
const int TOTALSUITES = 120;
for (int floor = 10; floor <= 16; floor++) {
if (floor != 13) {
do {
cout << "Please enter the number of suites occupied on the floor " << floor << ":";
cin >> numOccupied;
if ((numOccupied <0) || (numOccupied >20)) {
goodChoice = false;
cout << "\n\t\t**ERROR" << numOccupied << " ***\n\n";
cout << "*** Choice must be from [0-20]***\n";
}
else {
goodChoice = true;
}
totalOccupied += numOccupied;
} while (!goodChoice);
}
}
percentage = (totalOccupied/TOTALSUITES) * 100% ;
cout << endl;
cout << "Hotel has " << TOTALSUITES << endl;
cout << "Number of occupied suites is " << totalOccupied << endl;
cout << "The percentage of occupied suites is " << percentage << endl;
system("pause");
return 0;
在哪條線你會得到錯誤? – fabersky