どうやら精度を設定する方法がわかりません。このコードは、料金所を通過する車の料金を出力します。
void TollBooth::arrive(Car c)
{
carcount += 1;
int cost;
int doors = c.getDoors();
cost = 3 + doors;
total+=cost;
cout << setw(12) << left << "Car: "<< setw(8) <<c.getID()<< setw(8)
<< " Amount Due: $ " << setw(5) << fixed << right << setprecision(2) << cost << endl;
}
ただし、出力されるのは、後続ゼロのない「コスト」です。