Program not outputing values

It is probably something silly that I am overlooking, but my TaxRate and NetPay columns both give an amount of zero. Everything else works perfectly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

    int id[100], i=0, n=0; //hours worked
    double hw[100], rp[100], gp[100], otp[100], np[100], TR[100], ta[100]; //regular pay, gross, overtime pay, net, taxes, tax rate,
    double rh[100], oth[100], hr[100], otr[100]; //regular hours, overtime hours, hourly rate, overtime rate
    char fn[100][14], ln[100][15], st[100]; //first name/last name/status-married, single, head of household

	//functions
	void over(void){ //Overtime hours function
        for (i=0; i<n;i++)
        {
            if(hw[i] > 40)
            {
                oth[i] = hw[i] - 40;
                otr[i] = oth[i] * hr[i] * 1.5;
            }
            else
            {
                oth[i]=0, otr[i]=0;
            }
        }
    }// END Overtime hours function

    void pay(void){ // Pay function
        for (i=0; i<n;i++)
            {
            rp[i] = hw[i] * hr[i];
            if( oth[i] > 0)
            otp[i] = (hw[i] - 40) * hr[i] * 1.5;
            gp[i] = rp[i] + otp[i];
            } //  END Pay function
        }

    void tax(void){
        for (i=0; i<n;i++) // Tax function
            {
            if( gp[i] > 1000 ) TR[i] = 0.30;
            else if( gp[i] > 800) TR[i] = 0.20;
            else if( gp[i] > 500) TR[i] = 0.10;
            else TR[i] = 0.0;

            if (st[i]=='S') TR[i] = (TR[i] + .05);
            else if (st[i]=='M') TR[i] = (TR[i] * 1);
            else if (st[i]=='H' && gp[i] > 500) TR[i] = (TR[i] - .05);

            } // END Tax function
        }

    void net(void){
       for (i=0; i<n;i++) //Net pay function
            {
            ta[i] = gp[i] * TR[i];
            np[i] = gp[i] * (1.0- TR[i]);
            } // END Net pay function
        }

int main(){
    int over();
    int pay();
    int tax();
    ifstream fin ("employee.in");

while(fin>>id[n]>>hw[n]>>hr[n])n++;

    over();
    pay();
    tax();

    cout<<endl<<endl<<"DR. EBRAHIMI'S PAYROLL INSTITUTE"<<endl<<endl;

    cout<<"SSN #"<<"\t"<<"Hours"<<"\t"<<"Rate"<<"\t"<<"OverTime"<<"\t"<<"GrossPay"<<"\t"<<
        "TaxRate"<<"\t"<<"NetPay"<<endl<<endl;

        for (i=0; i<n;i++){
            {
            cout<<""<<id[i]<<"\t"<<hw[i]<<"\t"<<hr[i]<<"\t"<<otp[i]<<"\t\t"<<gp[i]<<"\t\t"
            <<ta[i]<<"\t"<<np[i]<<endl;
            }
        }

return 0;

}//MAIN
> but my TaxRate and NetPay columns both give an amount of zero.
¿where are you modifying them?

By the way, your use of global makes the code hard to follow.
I apologize for my coding style, it is a intro course I am taking and I am still learning the basics.

They are the last two functions, lines 38-51 and 53-59. The calculations worked in part A of the assignment, which concerns arrays and manually entering the data and getting output in tabular format.

Part B is modifying it to use functions and read data from an input file.
I think that I have it. I forgot

int net();
Topic archived. No new replies allowed.