So this is my code:
static_cast<double>(income_Tax = incomeTax*GrossAmount);
static_cast<double>(provincial_Tax = provincialTax*GrossAmount);
static_cast<double>(social_Security_Tax= socialSecurityTax*GrossAmount);
static_cast<double>(medicaid_Tax = medicare*GrossAmount);
static_cast<double>(pension_Plan = pensionPlan*GrossAmount);
static_cast<double>(health_Insurance = healthInsurance);
static_cast<double>(netPay = GrossAmount - (income_Tax + provincial_Tax + social_Security_Tax + medicaid_Tax + pension_Plan + health_Insurance));
What I am trying to achieve with this static_cast
here is: I want the values income_Tax
, netPay
, provincial_Tax
, etc. to have 2 decimal points, regardless of whether they are integers or not. But this is not happening.
Instead, I get 7 warnings (1 for each static cast) like this:
paychecks.cpp:66:5: warning: expression result unused [-Wunused-value]
static_cast<double>(netPay = GrossAmount - (income_Tax + provincial_Tax + social_Security_Tax + medicaid_Tax + pension_Plan + health_Insurance));
And the end result is something like this:
Gross Amount: ............$5000
Federal Income Tax: ......$750
Provincial Tax: ..........$175.4
Social Security Tax: .....$287.5
etc.
How do I make it so that the end values (e.g. netPay
) to be 2 decimal points, regardless of anything?