Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Adding variables to variables

Reply
Thread Tools

Adding variables to variables

 
 
lmo863
Guest
Posts: n/a
 
      08-03-2005
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

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-03-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Adding DotNet Variables to Javascript URL Elmo Watson ASP .Net 2 12-18-2007 05:06 PM
Embedded python adding variables linking to C++-Variables / callbacks iwl Python 3 12-07-2006 08:54 PM
Adding session variables to a JAX-RPC SOAP POJO? Scott Balmos Java 1 08-31-2005 07:50 PM
Adding custom server variables from http module Cybermedia Marketing ASP .Net 0 10-15-2003 06:51 PM



Advertisments