所以我正在尝试做一个薪水预测项目,但我被困在一件事上,我正在摆脱数字,它在小数位上给了我额外的 0,我不想要..
void calc(float *salary, float *rate, float *raise, float *newsalary)
{
*raise = *salary*(*rate);
*newsalary = (*salary)+(*raise);
}
void rateofsalary(float *salary, float *rate)//change this function into a return
{
if(*salary>=0 && *salary<=30000)
*rate = 7.0;
else
if(*salary>=30000 && *salary<=40000)
*rate = 5.5;
else
if(*salary>=40000)
*rate = 4.0;
}
输出如下:
> Please enter your salary: 25000
>The rate is: 7.00
>| | Salary |Rate | Raise | New Salary |
>| | 25000.00 | 7.00 | 175000.00 | 200000.00 |
> Press any key to continue . . .
但我想要的是:
> Please enter your salary: 25000
The rate is: 7.00
>| | Salary |Rate | Raise | New Salary |
| | 25000.00 | 7.00 | 1,750.00 | 26,750.00
> Press any key to continue . . .
为什么我会得到额外的 0?