calculator - some type of accumulator?

Lyrik514

New member
Joined
Apr 21, 2020
Messages
1
Programming Experience
Beginner
I'm trying to write a calculator app on a windows form based on some employee info. I will attach the app files so you can take a look if you want. I can't figure out how to get a total amount of pay broken down by the categories on the form based off of each employee that is entered into the app. I figured using some type of accumulator to store the total gross pay and increment it by the next value entered in would work but I don't know the syntax for that.
 

Attachments

  • Company Pay Calculator Solution.zip
    14.8 KB · Views: 14
Why don't you post the relevant code here instead of making us dig through your code that you posted. Tell us what kind of problem you are running into.

As an aside, there's a bug in your state tax computation. If someone make $500.50 cents as their gross pay, then the amount of state tax they need to pay is $500.50, not 4% of $500.50.
C#:
// getting State Income Tax Withheld
public double StateIncomeTax(double _payRate4, double _hoursWorked4)
{
    double stateTax = _payRate4 * _hoursWorked4;

    if (stateTax >= 0 || stateTax <= 500)
    {
        stateTax = stateTax * .02;
    }
    else
        if (stateTax >= 500.99 || stateTax <= 999.99)
        {
            stateTax = stateTax * .04;
        }
    else
        if (stateTax >= 1000)
        {
            stateTax = stateTax * .06;
        }
    return stateTax;  
}

A similar issue exists for the federal income tax. They will have to give all their income over to the federal government and the to the state government. So now they end up owing either the state or the federal government.
 
Back
Top Bottom