這是我的代碼開始的地方。在代碼的最底部,我將詳細說明錯誤點。我在Dev C++中發現一個錯誤(類型`const double'的無效操作數'和二元運算符<<'的<未知類型>')
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
//declare variables
int usedWater = 0;
int prevReading = 0;
int currReading = 0;
const double WATER_RATE = .007;
const double MIN_CHARGES = 16.67;
double totalCharges = 0.0;
cout <<"enter the current reading: ";
cin >> currReading;
cout <<"enter the previous reading: ";
cin >> prevReading;
usedWater = currReading - prevReading;
totalCharges = usedWater * WATER_RATE;
if(totalCharges < MIN_CHARGES)
{
totalCharges = MIN_CHARGES << endl;
cout << "total charges: " << MIN_CHARGES;
}
else
{
cout << "Total Charges : " << totalCharges;
}
cout << "total Charges : " << totalCharges;
cout << "Used Water : " << usedWater;
system ("pause");
return 0;
}
36行是我得到錯誤的地方。這:(totalCharges = MIN_CHARGES < < endl;)
我沒有看到任何錯別字。或者可能是一些錯誤的詞。
的'<< endl'掛最終沒有觸發任何警鐘? – nneonneo 2013-02-20 02:46:13
是導致問題的原因嗎? – RickTheSlick 2013-02-20 02:50:43
是的。是的。 – Johnsyweb 2013-02-20 03:03:01