【发布时间】:2013-03-10 21:14:52
【问题描述】:
我现在正在学习 C++ 课程并完成了我的期末作业。然而,有一件事情困扰着我:
虽然我对特定输出的测试有正确的输出,但basepay 应该是133.20,它显示为133.2。有没有办法让这个显示额外的 0 而不是关闭它?
有人知道这是否可能以及如何做吗?提前谢谢你
我的代码如下:
cout<< "Base Pay .................. = " << basepay << endl;
cout<< "Hours in Overtime ......... = " << overtime_hours << endl;
cout<< "Overtime Pay Amount........ = " << overtime_extra << endl;
cout<< "Total Pay ................. = " << iIndividualSalary << endl;
cout<< endl;
cout<< "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" <<endl;
cout<< "%%%% EMPLOYEE SUMMARY DATA%%%%%%%%%%%%%%%%%%%%%%%" <<endl;
cout<< "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" <<endl;
cout<< "%%%% Total Employee Salaries ..... = " << iTotal_salaries <<endl;
cout<< "%%%% Total Employee Hours ........ = " << iTotal_hours <<endl;
cout<< "%%%% Total Overtime Hours......... = " << iTotal_OvertimeHours <<endl;
cout<< "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
cout<< "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl;
【问题讨论】:
-
-1:代码应该是一个最小的工作示例。大多数粘贴的代码与问题无关。您能否编辑您的问题以减少它?
-
为您进行了编辑。抱歉,我对此仍然很陌生,并且不确定需要代码的哪一部分来帮助解决我的问题。谢谢!
-
谢谢。如果不确定,您可以根据sscce.org 中定义的短语“简短、独立、正确的示例”来定位。
标签: c++ floating-point iostream currency