我无法使“:”和“$”与用户通过 cin 命令(即“numTShirts”)实现的任何输入保持一致。如果实施 10 及以下,它会保持一致,但折扣与任何其他输入都不合适。
![用 10 实现] http://prntscr.com/gzms3m
![与其他实现] http://prntscr.com/gzmsjx
cout << "\n" << endl;
cout << fixed;
cout << "Thank you for your purchase.\n" << endl;
cout << "You bought " << numTShirts << " T-shirts\n" << endl;
cout << "Subtotal Total" << setw(5) << ": $ " << right << setprecision(2) << subTotal << "\n" << endl;
cout << setprecision(0) << "Discount(" << discountPCT << "%)" << setw(7) << ": $ " << right << showpoint << setprecision(2) << discount << "\n" << endl;
cout << setfill('-') << setw(35) << "-\n" << endl;
cout << setfill(' ');
cout << "Total" << setw(14) << ": $ " << right << showpoint << setprecision(2) << totalPrice << endl;