Array/Function issues... Things are going horribly wrong kind of

So Information is feeding great through my first function... Way to go first function! then I get a thread break point when the program goes to run through function: calculatePay. This would be easier if there were error messages but there aren't... I also tried to print out info after the first function and it's skipping right over those... if anyone could take a look at my code and help me debug this issue that would be greatly appreciated!!!!(I have a feeling I'm calling the function wrong...)

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

#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
using namespace std;


void getEMPdata(int[], int[], double[], int);
void calculatePay (int[],double[], double[], int);


int main(int argc, const char * argv[]) {
    
    int const size = 2;
    int empID[size] = {5658845, 4520125};// 7895122, 8777542, 845277, 1302850, 7580489};
    int hours[size];
    double payrate[size];
    double wages[size];
    
    
   
    
    cout << "Please enter the hours worked by employees and their hourly pay rates.\n\n";
    
    //set numeric formatting
    cout<<fixed<<showpoint<<setprecision(2);
   
    //get employee data
    getEMPdata(empID, hours, payrate ,size);
    
    
    cout<< empID[0] << hours[0]<< payrate[0];
    cout<< empID[1] << hours[1]<< payrate[1];
    
    //calc gross pay
    
    calculatePay (hours,payrate,wages,size);
    
   

   
    
    
    return 0;
}


void getEMPdata(int ID[], int hoursin[], double pay[] ,int size){
    
    for (int i = 0; i < size; i++) {
        cout<<"Employee: "<< ID[i] <<"\n";
        cout<<"Enter Hours: ";
        cin>> hoursin[i] ;
        
        cout<<"Enter Pay: $";
        cin>> pay[i];
        
        cout<<"\n";
        
    }}

void calculatePay (int hours[],double payrate[], double wages[], int size){

   
    double overtime = 0;
    int j = 0;
    for (; j < size; j++) {
        
    if (hours[j] > 40) {
        overtime = (hours[j] - 40) * payrate[j] * 1.5;
        wages[j] = (payrate[j] * 40) + overtime;
    }
     else
      wages[j] = hours[j] * payrate[j];
        cout<<"Gross: $"<< wages[j];
   
    }

}
Last edited on
then I get a thread break point when the program goes to run through function: calculatePay.

What is a thread break point? The program executes properly for me. The output has some format problems but it is working. By adding some end of line characters and space between numbers you should be able to see your output.
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
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
using namespace std;


void getEMPdata(int[], int[], double[], int);
void calculatePay (int[],double[], double[], int);


int main(int argc, const char * argv[]) {
    
    int const size = 2;
    int empID[size] = {5658845, 4520125};// 7895122, 8777542, 845277, 1302850, 7580489};
    int hours[size];
    double payrate[size];
    double wages[size];
    
    
   
    
    cout << "Please enter the hours worked by employees and their hourly pay rates.\n\n";
    
    //set numeric formatting
    cout<<fixed<<showpoint<<setprecision(2);
   
    //get employee data
    getEMPdata(empID, hours, payrate ,size);
    
    
    cout<< empID[0] << hours[0]<< " " << payrate[0] << endl;
    cout<< empID[1] << hours[1]<< " " << payrate[1] << endl;
    
    //calc gross pay
    
    calculatePay (hours,payrate,wages,size);
    
   

   
    
    
    return 0;
}


void getEMPdata(int ID[], int hoursin[], double pay[] ,int size){
    
    for (int i = 0; i < size; i++) {
        cout<<"Employee: "<< ID[i] <<"\n";
        cout<<"Enter Hours: ";
        cin>> hoursin[i] ;
        
        cout<<"Enter Pay: $";
        cin>> pay[i];
        
        cout<<"\n";
        
    }}

void calculatePay (int hours[],double payrate[], double wages[], int size){

   
    double overtime = 0;
    int j = 0;
    for (; j < size; j++) {
        
    if (hours[j] > 40) {
        overtime = (hours[j] - 40) * payrate[j] * 1.5;
        wages[j] = (payrate[j] * 40) + overtime;
    }
     else
      wages[j] = hours[j] * payrate[j];
        cout<<"Gross: $"<< wages[j] << endl;
   
    }

}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Please enter the hours worked by employees and their hourly pay rates.

Employee: 5658845
Enter Hours: 5
Enter Pay: $5

Employee: 4520125
Enter Hours: 5
Enter Pay: $5

56588455 5.00
45201255 5.00
Gross: $25.00
Gross: $25.00
 
Exit code: 0 (normal program termination)
jlb!! Thanks I thought I was going crazy... This is why it's great to have an extra pair of eyes sometimes. Thanks for noticing what I couldn't!
Topic archived. No new replies allowed.