Solved

figuring out a calculation in a programmer defined function.

Posted on 2000-03-07
3
190 Views
Last Modified: 2010-04-02
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 =


0
Comment
Question by:nationnon
  • 2
3 Comments
 

Accepted Solution

by:
jclayton earned 35 total points
ID: 2591011
totalDeductions = numberInput * 0.425;

0
 

Expert Comment

by:jclayton
ID: 2591015
Oops, to return that value from the method call - simply do this:

float func(float input)
{
float reduction = 0.425;
return input * reduction;
}

// and is used like this
float netpay = func(grosspay);
0
 
LVL 22

Expert Comment

by:nietod
ID: 2591691
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
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question