返回2位小数的值

时间:2017-03-31 02:45:55

标签: c++

我不知道如何返回带有2位小数的值,因为我们不允许编辑输出值的主要位置。返回的值是315,但我想返回315.00

//cpp file
double SavingsAccount::calculateInterest()
{
    double x = interestRate*getBalance();  //getBalance() is whatever the balance value is which in this case is $2100
                                           // and interestRate is in this case 0.15
return x;
}

0 个答案:

没有答案