I'm trying to build a simple payroll code

This is supposed to be a simple payroll calculation program but i seem to be having a small problem. this is the current code and it will now work, but it doesn't tell me what the issue is. It stops working in the middle of the code and displays a message that reads " this program has unexpectedly stopped working". i don't understand it.

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
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main ()
{
    const int emp=7;
    int workers[emp] = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489
        };
        int hours[emp];
        double payroll[emp];
        int index;
        for (int index = 0; index < emp; index++)
            
            do
	{
		cout << "Please enter the hours worked by employee number " << (index+1) << " (ID = " << workers[index] << ") : ";
		cin >> hours[index];

		if(hours[index] < 0)
		{
			cout << "Enter in a positive number" << endl; 
		}
	}
	while(hours[index] < 0); 
	
	do
	{
		{cout << "Please enter the pay rate for employee number "<< (index+1) << " (ID = " << workers[index] << ") : ";
		cin >> payroll[index];}

		if(payroll[index] < 6)
		{
			cout << "The pay rate must be >= 6" << endl; 
		}
	}
	while(hours[index] < 0);
	for (int index = 0; index < emp; index++)
	{
        double paycheck = hours[index] * payroll[index];
	cout << "Employee #" << (index + 1);
	cout << ": earned $" << paycheck << endl;
        }
        
    system("pause");
    return 0;
    }
Last edited on
you didn't define index and empId
Last edited on
well i set it to 7 but i think i need to set it to nothing right?
i re did it and it just stops now, not because of the code just for no reason.
I don't know why it unexpectedly stopped working if anyone can tell me why that is or if it works for them, that would be awesome.
Topic archived. No new replies allowed.