passing arrays to functions

hi guys, need your brains. I'm getting an error when trying to compile.
"variable of field "Input" declared void" What's wrong with void? I'm not
returning anything in the function. help please!

Also, I know I have to use typedef for strings, but I haven't figured out how to do that yet.

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <cstdlib>
#include <iostream>
#include <string>
#include <iomanip>
#include <istream>
#include <fstream>

//prototypes
void Input(string[],string[],string[],double[]);
void MyGross(double[],double[],int[]);
void MyState(double[],double[],const double);
void MyFed(double[],double[],const double);
void MyUnion(double[],double[],const double);
void MyNet(double[],double[],double[],double[],double[]);
void Output(string[],string[],string[],double[],int[],double[],double[],double[],double[]);

using namespace std;

int main()
{
    const double STATETAX = .05;
    const double FEDTAX = .15;
    const double UNIONFEES = .02;
    const double OTRATE = 1.5;
    const int SIZE = 5;
    string fname[SIZE], lname[SIZE], mname[SIZE], id[SIZE];
    char answer;
    int hours[SIZE], level[SIZE];
    double rate[SIZE], myGross[SIZE], myStateTax[SIZE], myFedTax[SIZE], myUnionFees[SIZE];
    double myNet[SIZE];
    
    do
    {
         Input(fname,lname,id,rate)                                             
         MyGross(myGross,rate,hours)
         MyState(myStateTax,myGross,STATETAX)
         MyFed(myFedTax,myGross,FEDTAX)
         MyUnion(myUnion,myGross,UNIONFEES)
         MyNet(myNet,myGross,myStateTax,myFedTax,myUnionFees)
         
         cout << "Do you have another employee to enter? (Y or N) ";
         cin >> answer;
         if (answer == 'Y')
              break;
         else
              idx = SIZE;
         } 
        
    } while(answer == 'Y' || answer == 'y'); 
    cout << endl << endl;
    
    /**************************************************************************
    Input function to populate the arrays.
    **************************************************************************/
    void Input(string fname[],string lname[],string id[],double rate[])
    {
         for(int idx = 0; idx < SIZE; idx++)  
         {                   
              cout << "Enter the following employee info." << endl;
              cout << "First name: ";
              cin >> fname[idx];
              cout << "Last name: ";
              cin >> lname[idx];

              do
              {    
              cout << "Employee ID#: ";
              cin >> id[idx];
              if (id[idx].size() == 6)
                   break;
              else
                   cout << "Invalid employee ID#. Must be 6 characters. Try again.\n";
              } while(1);
    
              do
              {
              cout << "Hourly Rate: $";
              cin >> rate[idx];
              
              if (rate[idx] > 0)
                   break;
              else
                   cout << "Invalid pay rate. Must be > $0.00. Try again.\n ";
              } while (1); 
         }
    }
    
    /**************************************************************************
    MyGross function to calculate gross pay and populate the array.
    **************************************************************************/
    void MyGross(double myGross[],double rate[],int hours[])
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myGross[idx] = rate[idx] * 40 + (hours[idx]) * 1.5;        
    }
    
    /**************************************************************************
    MyState function to calculate state tax paid and populate the array.
    **************************************************************************/
    void MyState(double myStateTax[],double myGross[],const double STATETAX)
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myStateTax[idx] = myGross[idx] * STATETAX;        
    }
    
    /**************************************************************************
    MyFed function to calculate fed tax paid and populate the array.
    **************************************************************************/
    void MyFed(double myFedTax[],double myGross[],const double FEDTAX)
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myFedTax[idx] = myGross[idx] * FEDTAX;        
    }
    
    /**************************************************************************
    MyUnion function to calculate union fees paid and populate the array.
    **************************************************************************/
    void MyUnion(double myUnion[],double myGross[],const double UNIONFEES)
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myUnion[idx] = myGross[idx] * UNIONFEES;        
    }
    
    /**************************************************************************
    MyNet function to calculate net income and populate the array.
    **************************************************************************/
    void MyNet(double myNet[],double myGross[],double myStateTax[],double myFedTax[],double myUnionFees[])
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myNet[idx] = myGross[idx] - (myStateTax[idx] + myFedTax[idx] + myUnionFees[idx]);        
    }
    
        
    /**************************************************************************
    Output function to display the arrays.
    **************************************************************************/
    void Output(string fname[],string lname[],string id[],double rate[],int hours[],double myGross[],double myStateTax[],double myFedTax[],double myNet[])
    cout << "\t\t\tCompany A B C" << endl;
    cout << "\t\t\t= = = = = = =" << endl;
    cout << "\t\t\tPay  Roll  Program" << endl;
    cout << "======================================================================";
    cout << "==========" << endl;
    cout << "Name  " << "Id#  " << "Rate/h  " << "OT hours  " << "Gross  ";
    cout << "State Tax  " << "Fed Tax  " << "Union Fees  " << "Net   " << endl;
    cout << "====          " << "===    " << "======    " << "========    " << "=====    ";
    cout << "=========    " << "=======    " << "==========    " << "====    " << endl;
    
    for(int idx = 0; idx < SIZE; idx++) 
    }
         cout << fname[idx] << "     " << lname[idx] << "    " << id[idx];
         cout << "    " << rate[idx] << "    " << hours[idx] << "     " << myGross[idx];
         cout << "     " << myStateTax[idx] << "    " << myFedTax[idx] << "    ";
         cout << myUnionFees[idx] << "    " << myNet[idx] << endl; 
    }
    
       
    system("PAUSE");
    return EXIT_SUCCESS;

}
You messed up the brackets of main(). Also lines 34 to 39 are missing the semicolon.
Last edited on
Thanks, added the semicolons. Did you mean the exit and the closed bracket of main()? I moved it up to lines 51 just before the functions begin. But I'm still getting the same compile error.

"variable of field "Input" declared void"

1
2
3
4
    system("PAUSE");
    return EXIT_SUCCESS;

}
The bracket on line 33 is closed on line 47, and the bracket on line 49 is the one closing main().
Also move using namespace std before the declarations.

On which line are you getting the error?
ah gotcha!
But I'm still getting this error on line 9 when compiling:
"variable of field "Input" declared void"
Not sure what is wrong with void here.


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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include <cstdlib>
#include <iostream>
#include <string>
#include <iomanip>
#include <istream>
#include <fstream>

//prototypes
void Input(string[],string[],string[],double[]);
void MyGross(double[],double[],int[]);
void MyState(double[],double[],const double);
void MyFed(double[],double[],const double);
void MyUnion(double[],double[],const double);
void MyNet(double[],double[],double[],double[],double[]);
void Output(string[],string[],string[],double[],int[],double[],double[],double[],double[]);

using namespace std;

int main()
{
    const double STATETAX = .05;
    const double FEDTAX = .15;
    const double UNIONFEES = .02;
    const double OTRATE = 1.5;
    const int SIZE = 5;
    string fname[SIZE], lname[SIZE], mname[SIZE], id[SIZE];
    char answer;
    int hours[SIZE], level[SIZE];
    double rate[SIZE], myGross[SIZE], myStateTax[SIZE], myFedTax[SIZE], myUnionFees[SIZE];
    double myNet[SIZE];
    /*
    ofstream outputFile;
    outputFile.open("E:\\CIS265\\PayrollProgram.txt");
    */
    do
    {
         Input(fname,lname,id,rate);                                             
         MyGross(myGross,rate,hours);
         MyState(myStateTax,myGross,STATETAX);
         MyFed(myFedTax,myGross,FEDTAX);
         MyUnion(myUnion,myGross,UNIONFEES);
         MyNet(myNet,myGross,myStateTax,myFedTax,myUnionFees);
         
         cout << "Do you have another employee to enter? (Y or N) ";
         cin >> answer;
         if (answer == 'Y')
              break;
         else
              idx = SIZE;
    }while(answer == 'Y' || answer == 'y');
        
} 
    cout << endl << endl;

    system("PAUSE");
    return EXIT_SUCCESS;

}

    /**************************************************************************
    Input function to populate the arrays.
    **************************************************************************/
    void Input(string fname[],string lname[],string id[],double rate[])
    {
         for(int idx = 0; idx < SIZE; idx++)  
         {                   
              cout << "Enter the following employee info." << endl;
              cout << "First name: ";
              cin >> fname[idx];
              cout << "Last name: ";
              cin >> lname[idx];

              do
              {    
              cout << "Employee ID#: ";
              cin >> id[idx];
              if (id[idx].size() == 6)
                   break;
              else
                   cout << "Invalid employee ID#. Must be 6 characters. Try again.\n";
              } while(1);
    
              do
              {
              cout << "Hourly Rate: $";
              cin >> rate[idx];
              
              if (rate[idx] > 0)
                   break;
              else
                   cout << "Invalid pay rate. Must be > $0.00. Try again.\n ";
              } while (1); 
         }
    }
    
    /**************************************************************************
    MyGross function to calculate gross pay and populate the array.
    **************************************************************************/
    void MyGross(double myGross[],double rate[],int hours[])
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myGross[idx] = rate[idx] * 40 + (hours[idx]) * 1.5;        
    }
    
    /**************************************************************************
    MyState function to calculate state tax paid and populate the array.
    **************************************************************************/
    void MyState(double myStateTax[],double myGross[],const double STATETAX)
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myStateTax[idx] = myGross[idx] * STATETAX;        
    }
    
    /**************************************************************************
    MyFed function to calculate fed tax paid and populate the array.
    **************************************************************************/
    void MyFed(double myFedTax[],double myGross[],const double FEDTAX)
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myFedTax[idx] = myGross[idx] * FEDTAX;        
    }
    
    /**************************************************************************
    MyUnion function to calculate union fees paid and populate the array.
    **************************************************************************/
    void MyUnion(double myUnion[],double myGross[],const double UNIONFEES)
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myUnion[idx] = myGross[idx] * UNIONFEES;        
    }
    
    /**************************************************************************
    MyNet function to calculate net income and populate the array.
    **************************************************************************/
    void MyNet(double myNet[],double myGross[],double myStateTax[],double myFedTax[],double myUnionFees[])
    for(int idx = 0; idx < SIZE; idx++) 
    {
         myNet[idx] = myGross[idx] - (myStateTax[idx] + myFedTax[idx] + myUnionFees[idx]);        
    }
    
        
    /**************************************************************************
    Output function to display the arrays.
    **************************************************************************/
    void Output(string fname[],string lname[],string id[],double rate[],int hours[],double myGross[],double myStateTax[],double myFedTax[],double myNet[])
    cout << "\t\t\tCompany A B C" << endl;
    cout << "\t\t\t= = = = = = =" << endl;
    cout << "\t\t\tPay  Roll  Program" << endl;
    cout << "======================================================================";
    cout << "==========" << endl;
    cout << "Name  " << "Id#  " << "Rate/h  " << "OT hours  " << "Gross  ";
    cout << "State Tax  " << "Fed Tax  " << "Union Fees  " << "Net   " << endl;
    cout << "====          " << "===    " << "======    " << "========    " << "=====    ";
    cout << "=========    " << "=======    " << "==========    " << "====    " << endl;
    
    for(int idx = 0; idx < SIZE; idx++) 
    }
         cout << fname[idx] << "     " << lname[idx] << "    " << id[idx];
         cout << "    " << rate[idx] << "    " << hours[idx] << "     " << myGross[idx];
         cout << "     " << myStateTax[idx] << "    " << myFedTax[idx] << "    ";
         cout << myUnionFees[idx] << "    " << myNet[idx] << endl; 
    }
I wrote:
Also move using namespace std before the declarations.

It is surprising however. I would have expected a 'string does not name a type' error.
Last edited on
ok making progress!! yay!! it was the 'using namespace' that I needed to move. I found several more errors and fixed. Now another snag:

line 102: expected init-declarator before "for"


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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <cstdlib>
#include <iostream>
#include <string>
#include <iomanip>
#include <istream>
#include <fstream>

using namespace std;

//prototypes
void Input(string[],string[],string[],double[]);
void MyGross(double[],double[],int[]);
void MyState(double[],double[],const double);
void MyFed(double[],double[],const double);
void MyUnion(double[],double[],const double);
void MyNet(double[],double[],double[],double[],double[]);
void Output(string[],string[],string[],double[],int[],double[],double[],double[],double[]);



int main()
{
    const double STATETAX = .05;
    const double FEDTAX = .15;
    const double UNIONFEES = .02;
    const double OTRATE = 1.5;
    const int SIZE = 5;
    string fname[SIZE], lname[SIZE], mname[SIZE], id[SIZE];
    char answer;
    int hours[SIZE], level[SIZE], idx;
    double rate[SIZE], myGross[SIZE], myStateTax[SIZE], myFedTax[SIZE], myUnionFees[SIZE];
    double myNet[SIZE];
    /*
    ofstream outputFile;
    outputFile.open("E:\\CIS265\\PayrollProgram.txt");
    */
    do
    {
         Input(fname,lname,id,rate);                                             
         MyGross(myGross,rate,hours);
         MyState(myStateTax,myGross,STATETAX);
         MyFed(myFedTax,myGross,FEDTAX);
         MyUnion(myUnionFees,myGross,UNIONFEES);
         MyNet(myNet,myGross,myStateTax,myFedTax,myUnionFees);
         
         cout << "Do you have another employee to enter? (Y or N) ";
         cin >> answer;
         if (answer == 'Y')
              break;
         else
              idx = SIZE;
    }while(answer == 'Y' || answer == 'y');
        
 
    cout << endl << endl;

    system("PAUSE");
    return EXIT_SUCCESS;

}

    /**************************************************************************
    Input function to populate the arrays.
    **************************************************************************/
    void Input(string fname[],string lname[],string id[],double rate[],const int SIZE)
    {
         for(int idx = 0; idx < SIZE; idx++)  
         {                   
              cout << "Enter the following employee info." << endl;
              cout << "First name: ";
              cin >> fname[idx];
              cout << "Last name: ";
              cin >> lname[idx];

              do
              {    
              cout << "Employee ID#: ";
              cin >> id[idx];
              if (id[idx].size() == 6)
                   break;
              else
                   cout << "Invalid employee ID#. Must be 6 characters. Try again.\n";
              } while(1);
    
              do
              {
              cout << "Hourly Rate: $";
              cin >> rate[idx];
              
              if (rate[idx] > 0)
                   break;
              else
                   cout << "Invalid pay rate. Must be > $0.00. Try again.\n ";
              } while (1); 
         }
    }
    
    /**************************************************************************
    MyGross function to calculate gross pay and populate the array.
    **************************************************************************/
    void MyGross(double myGross[],double rate[],int hours[],const int SIZE)
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myGross[idx] = rate[idx] * 40 + (hours[idx]) * 1.5;        
         }
    
    /**************************************************************************
    MyState function to calculate state tax paid and populate the array.
    **************************************************************************/
    void MyState(double myStateTax[],double myGross[],const double STATETAX)
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myStateTax[idx] = myGross[idx] * STATETAX;        
         }
    
    /**************************************************************************
    MyFed function to calculate fed tax paid and populate the array.
    **************************************************************************/
    void MyFed(double myFedTax[],double myGross[],const double FEDTAX)
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myFedTax[idx] = myGross[idx] * FEDTAX;        
         }
    
    /**************************************************************************
    MyUnion function to calculate union fees paid and populate the array.
    **************************************************************************/
    void MyUnion(double myUnion[],double myGross[],const double UNIONFEES)
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myUnion[idx] = myGross[idx] * UNIONFEES;        
         }
    
    /**************************************************************************
    MyNet function to calculate net income and populate the array.
    **************************************************************************/
    void MyNet(double myNet[],double myGross[],double myStateTax[],double myFedTax[],double myUnionFees[])
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myNet[idx] = myGross[idx] - (myStateTax[idx] + myFedTax[idx] + myUnionFees[idx]);        
         }
    
        
    /**************************************************************************
    Output function to display the arrays.
    **************************************************************************/
    void Output(string fname[],string lname[],string id[],double rate[],int hours[],double myGross[],double myStateTax[],double myFedTax[],double myNet[])
    cout << "\t\t\tCompany A B C" << endl;
    cout << "\t\t\t= = = = = = =" << endl;
    cout << "\t\t\tPay  Roll  Program" << endl;
    cout << "======================================================================";
    cout << "==========" << endl;
    cout << "Name  " << "Id#  " << "Rate/h  " << "OT hours  " << "Gross  ";
    cout << "State Tax  " << "Fed Tax  " << "Union Fees  " << "Net   " << endl;
    cout << "====          " << "===    " << "======    " << "========    " << "=====    ";
    cout << "=========    " << "=======    " << "==========    " << "====    " << endl;
    
    for(int idx = 0; idx < SIZE; idx++) 
    }
         cout << fname[idx] << "     " << lname[idx] << "    " << id[idx];
         cout << "    " << rate[idx] << "    " << hours[idx] << "     " << myGross[idx];
         cout << "     " << myStateTax[idx] << "    " << myFedTax[idx] << "    ";
         cout << myUnionFees[idx] << "    " << myNet[idx] << endl; 
    }
    
    /**************************************************************************
    Write to file function to populate the arrays.
    **************************************************************************
    for(int idx = 0; idx < SIZE; idx++)
    {
         outputFile << fname[idx] << "    " << lname[idx] << "    " << id[idx];
         outputFile << "    " << rate[idx] << "    " << hours[idx] << "     " << myGross[idx];
         outputFile << "     " << myStateTax[idx] << "    " << myFedTax[idx] << "    ";
         outputFile << myUnionFees[idx] << "    " << myNet[idx] << endl;
    }
    */
You forgot the brackets for the function definition. And not only there.
Duh. Thanks. That was stupid of me!!

I was able to get this to compile finally! Now my loop doesn't seem to work after I ask whether the user has another entry (lines 88-93). It's supposed to loop within the function until user enters N or something other than Y. But no matter what I enter, It goes back to Main and I get output (incorrect output, but I'll get to that soon enough) Is it the "break;"?



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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include <cstdlib>
#include <iostream>
#include <string>
#include <iomanip>
#include <istream>
#include <fstream>

const int SIZE_A = 20;        //Set array size for first and last name input
const int SIZE_B = 8;        //Set array size for ID input
          
typedef char String_A[SIZE_A];         
typedef char String_B[SIZE_B];

//prototypes
void Input(String_A[],String_A[],String_B[],double[],const int,char);
void MyGross(double[],double[],int[],const int);
void MyState(double[],double[],const double,const int);
void MyFed(double[],double[],const double,const int);
void MyUnion(double[],double[],const double,const int);
void MyNet(double[],double[],double[],double[],double[],const int);
void Output(String_A[],String_A[],String_B[],double[],int[],double[],double[],double[],double[],double[],const int);

using namespace std;

int main()
{
    const double STATETAX = .05;
    const double FEDTAX = .15;
    const double UNIONFEES = .02;
    const double OTRATE = 1.5;
    const int SIZE = 5;
    //string fname[SIZE], lname[SIZE], mname[SIZE], id[SIZE];
    String_A fname[SIZE], lname[SIZE];    
    String_B id[SIZE]; 
    char answer;
    int hours[SIZE], level[SIZE], idx;
    double rate[SIZE], myGross[SIZE], myStateTax[SIZE], myFedTax[SIZE], myUnionFees[SIZE];
    double myNet[SIZE];
    
    do
    {
         Input(fname,lname,id,rate,SIZE,answer);                                             
         MyGross(myGross,rate,hours,SIZE);
         MyState(myStateTax,myGross,STATETAX,SIZE);
         MyFed(myFedTax,myGross,FEDTAX,SIZE);
         MyUnion(myUnionFees,myGross,UNIONFEES,SIZE);
         MyNet(myNet,myGross,myStateTax,myFedTax,myUnionFees,SIZE);
         Output(fname,lname,id,rate,hours,myGross,myStateTax,myFedTax,myUnionFees,myNet,SIZE);
         
         
    }while(1);
        
 
    cout << endl << endl;

    system("PAUSE");
    return EXIT_SUCCESS;

}

    /**************************************************************************
    Input function to populate the arrays.
    **************************************************************************/
    void Input(String_A fname[],String_A lname[],String_B id[],double rate[],const int SIZE,char answer)
    {
         for(int idx = 0; idx < SIZE; idx++)  
         {                  
              char answer;               
              cout << "Enter the following employee info." << endl;
              cout << "First name: ";
              cin >> fname[idx];
              cout << "Last name: ";
              cin >> lname[idx];
              cout << "Employee ID#: ";
              cin >> id[idx];
              
              do
              {
              cout << "Hourly Rate: $";
              cin >> rate[idx];
              
              if (rate[idx] > 0)
                   break;
              else
                   cout << "Invalid pay rate. Must be > $0.00. Try again.\n ";
              } while (1);
              
              cout << "Do you have another employee to enter? (Y or N) ";
              cin >> answer;
              if (answer == 'Y')
                   break;
              else
                   idx = SIZE;
               
         }
    }
    
    /**************************************************************************
    MyGross function to calculate gross pay and populate the array.
    **************************************************************************/
    void MyGross(double myGross[],double rate[],int hours[],const int SIZE)
    {
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myGross[idx] = rate[idx] * 40 + (hours[idx]) * 1.5;        
         }
    }
    
    /**************************************************************************
    MyState function to calculate state tax paid and populate the array.
    **************************************************************************/
    void MyState(double myStateTax[],double myGross[],const double STATETAX,const int SIZE)
    {
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myStateTax[idx] = myGross[idx] * STATETAX;        
         }
    } 
    
    /**************************************************************************
    MyFed function to calculate fed tax paid and populate the array.
    **************************************************************************/
    void MyFed(double myFedTax[],double myGross[],const double FEDTAX,const int SIZE)
    {
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myFedTax[idx] = myGross[idx] * FEDTAX;        
         }
    }
    
    /**************************************************************************
    MyUnion function to calculate union fees paid and populate the array.
    **************************************************************************/
    void MyUnion(double myUnion[],double myGross[],const double UNIONFEES,const int SIZE)
    {
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myUnion[idx] = myGross[idx] * UNIONFEES;        
         }
    }
    
    /**************************************************************************
    MyNet function to calculate net income and populate the array.
    **************************************************************************/
    void MyNet(double myNet[],double myGross[],double myStateTax[],double myFedTax[],double myUnionFees[],const int SIZE)
    {
         for(int idx = 0; idx < SIZE; idx++) 
         {
              myNet[idx] = myGross[idx] - (myStateTax[idx] + myFedTax[idx] + myUnionFees[idx]);        
         }
    }
    
        
    /**************************************************************************
    Output function to display the arrays.
    **************************************************************************/
    void Output(String_A fname[],String_A lname[],String_B id[],double rate[],int hours[],double myGross[],double myStateTax[],double myFedTax[],double myUnionFees[],double myNet[],const int SIZE)
    {
         cout << "\n\n\t\t\tCompany A B C" << endl;
         cout << "\t\t\t= = = = = = =" << endl;
         cout << "\t\t\tPay  Roll  Program" << endl;
         cout << "======================================================================";
         cout << "==========" << endl;
         cout << "Name  " << "Id#  " << "Rate/h  " << "OT hours  " << "Gross  ";
         cout << "State Tax  " << "Fed Tax  " << "Union Fees  " << "Net   " << endl;
         cout << "====          " << "===    " << "======    " << "========    " << "=====    ";
         cout << "=========    " << "=======    " << "==========    " << "====    " << endl;
    
         for(int idx = 0; idx < SIZE; idx++) 
         {
              cout << fname[idx] << " " << lname[idx] << "    " << id[idx];
              cout << "    " << rate[idx] << "    " << hours[idx] << "     " << myGross[idx];
              cout << "     " << myStateTax[idx] << "    " << myFedTax[idx] << "    ";
              cout << myUnionFees[idx] << "    " << myNet[idx] << endl; 
         }
    
         ofstream outputFile;
         outputFile.open("E:\\CIS265\\PayrollProgram.txt");
    
         for(int idx = 0; idx < SIZE; idx++)
         {
              outputFile << fname[idx] << " " << lname[idx] << "    " << id[idx];
              outputFile << "    " << rate[idx] << "    " << hours[idx] << "     " << myGross[idx];
              outputFile << "     " << myStateTax[idx] << "    " << myFedTax[idx] << "    ";
              outputFile << myUnionFees[idx] << "    " << myNet[idx] << endl;
         }
    
    
    }
Oops I kinda forgot to reply, sorry.
Anyway, the break on line 91 affects the for, so if the user enters "Y" it stops. On the other hand, if he enters anything else 'idx' is set to SIZE and the condition of the for becomes false, ending(?) it.
What if user enters 2 employees? Then the entire program will print irrelevant information for 3 other employees since you are using the variable SIZE to determine how much output to print. A fix will be to not set size to a const and in the first function (input), what you have to check for on line 90 is:

1
2
if (toupper(answer) != 'Y')
     SIZE = idx + 1;
Topic archived. No new replies allowed.