Solved

figuring out a calculation in a programmer defined function.

Posted on 2000-03-07
3
180 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now