tabstop/daved:
Err, yeah. I have 5 elements
but total[5] allows you to edit
total[0]
total[1]
total[2]
total[3]
total[4]
total[5]
which is actually 6 elements.
I only need to go up to total[4].
Also, pretty much the same thing works in a different segment of code, where
float money[slot][4]
money[][0]=blah
money[][1]=blah
money[][2]=blah
money[][3]=blah
money[][4]=blah
and it works <i>just fine</i>
oh well, if float total[5] works, it works, even if it doesn't match up completely with money[][4].
However, I do have a new question which is pretty perplexing:
Code:
float money[40][4]; //gross, fedtax, health, fica, net
for (i=0;i<slot;i++)
{
money[i][0]=c_gross(rate[i],hours[i]);
money[i][1]=c_fed(money[i][0]);
money[i][2]=c_health(money[i][0],dependents[i],health[i]);
money[i][3]=c_fica(money[i][0]);
money[i][4]=c_net(money[i][0],money[i][1],money[i][2],money[i][3]);
cout<<"\n";
cout<<i<<": "<<money[i][0]<<"-"<<money[i][1]<<"-"<<money[i][2]<<"-"<<money[i][3]<<"="<<(money[i][0]-money[i][1]-money[i][2]-money[i][3]);
cout<<" ACTUAL: "<<money[i][4];
cout<<" 0th actual: "<<money[0][4];
}
I have a different problem in this code.
The c_gross, c_fed etc is there just to calculate money[i][0],[1] etc.
money[][0] is gross
[1],[2],[3] is tax [I wasn't completely honest in my first post because you guys didn't need to know about gross/net]
[4] is net.
This is what my program outputs
Code:
Welcome to BLAG
Name: 1
Hours: 12
Rate: 12
Dependents: 1
Health: 1
New employee? (Y or N): y
Name: 2
Hours: 1
Rate: 1
Dependents: 1
Health: 1
New employee? (Y or N): y
Name: 4
Hours: 4
Rate: 4
Dependents: 4
Health: 1
New employee? (Y or N): n
//THIS IS FROM THE CODE SNIPPET
0: 144.00-0.00-18.75-12.24=113.01 ACTUAL: 113.01 0th actual: 113.01 //Correct!!
1: 1.00-0.00-18.75-0.09=-17.83 ACTUAL: -17.83 0th actual: 1.00 //0th net equals gross[1][0] now!
2: 16.00-0.00-40.80-1.36=-26.16 ACTUAL: -26.16 0th actual: 1.00
//END CODE SNIPPET
HOURS PAY GROSS FED HEALTH NET
NAME WORKED RATE PAY TAX FICA PLAN PAY
1 12 12.00 144.00 0.00 18.75 12.24 1.00
2 1 1.00 1.00 0.00 18.75 0.09 16.00
4 4 4.00 16.00 0.00 40.80 1.36 -26.16
TOTAL 17 17.00 161.00 0.00 78.30 13.68 -9.16
Press any key to continue . . .
The problem is, money[0][4] (which represents the first guy's net) is changed into money[1][0] (which represents the second guy's gross).
0th person's net becomes 1st person's gross
1st person's net becomes 2nd person's gross
2nd person's net remains the same. //good!