Solved

figuring out a calculation in a programmer defined function.

Posted on 2000-03-07
3
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

751 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