By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,122 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,122 IT Pros & Developers. It's quick & easy.

Adding variables to variables

P: n/a
Hi,

I wonder if anyone can help me. I am creating a program in Borland C++
Builder. I want to do the following...

A variable, TotalTax, calculates the tax for an employee. I need to
also keep a running total for "n" employees. So i need a piece of code
to add the next value of TotalTax to the current value.

I have tried the following code;

TotalTax = TotalTax + TotalTax1 (where totaltax1 is the new value )

but it just keeps doubling the value in the original.

Does anyone know an easier way to do this, bearing in mind I have four
IF statements to determine what tax the employee has to pay!

thanks in advance

Aug 3 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
lmo863 wrote:
I wonder if anyone can help me. I am creating a program in Borland C++
Builder. I want to do the following...

A variable, TotalTax, calculates the tax for an employee. I need to
also keep a running total for "n" employees. So i need a piece of code
to add the next value of TotalTax to the current value.

I have tried the following code;

TotalTax = TotalTax + TotalTax1 (where totaltax1 is the new value )

but it just keeps doubling the value in the original.

Does anyone know an easier way to do this, bearing in mind I have four
IF statements to determine what tax the employee has to pay!


The "easier" way to do what you have above is

TotalTax += TotalTax1

but it will probably not fix your doubling issue because it is reasonable
to assume that it's not due to this addition, but due to calculation of
'TotalTax1'.

Since you're the one who's in charge of making your code work, you will
have to put some more effort to it. You have what is known as "a bug" in
your code. So, you have to de-bug your program. Use a "debugger" or do
a manual trace of your program with a pencil and a piece of paper, just
do it. We cannot do it for you because we don't have your code.

V
Aug 3 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.