nationnon
asked on
figuring out a calculation in a programmer defined function.
Ok here's my question. I am trying to deduct 45% from a gross pay. I haven't the slightest idea how to insert the formula or what it's suppost to look like. Here's what I got so far.
float calcDeductions(float numberInput)
{
//declare and initialize variable
float totalDeductions = 0.425;
//calculate Deductions
totalDeductions =
float calcDeductions(float numberInput)
{
//declare and initialize variable
float totalDeductions = 0.425;
//calculate Deductions
totalDeductions =
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not quit, that calculates the deduction, not the net
i.e you have
float deduction = gross*0.425;
but you want
float net = gross*(1 - 0.425);
or
float net = gross*0.575
i.e you have
float deduction = gross*0.425;
but you want
float net = gross*(1 - 0.425);
or
float net = gross*0.575
float func(float input)
{
float reduction = 0.425;
return input * reduction;
}
// and is used like this
float netpay = func(grosspay);