Not running the loop

In this program, I am trying to have users enter the ID of an employee, and then have the function SearchList find the correct ID and display the respective wage, and how much above max/min that go with it. Everything is running correctly except the function SearchList. Does anyone know what the problem is?

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
# include <iostream>
using namespace std;

int SearchList (long EmpId [], Wages [], int size){
	long x;
	int max = Wages [0];
	int min = Wages [0];
	
	
	for (int a = 0; a < size; a++){
		if (Wages[a] > max)
			max = Wages[a];
	}
	for (int a= 0; a < size; a++)
		if (Wages [a] < min)
			min = Wages [a];
	}

	int i = 0;
	int position = -1;
	bool found = false;
	
	cout<<"Please enter Emloyee ID:";
	cin >> x;


	while (i < size && !found){
		if (EmpID[i] == x){
			found = true;
			position = i;
			cout<<"This employee's gross wage is" << Wages [i]; 
			cout<<"The wage is"<< max - Wages [i] << "below the max wage."<<endl;
			cout<<"The wage is"<<Wages [i] - min << "above the min wage."<<endl;
	}
		i++;
	}
			
	return position;
}




void getHours (long EmpID [],int Hours [], int size){
	int i;
	
	for (i=0; i<size; i++){
		cout<<"Employee"<<" "<< EmpID [i]<< "hours:"; 
		cin >> Hours [i]; 
		
		while (Hours [i] < 0){
			cout<<"Invalid"<<endl;
			cout<<"Employee"<<" "<< EmpID [i] <<"hours:";
			cin >>Hours [i]; 
		}
	}
}

void getPayRate (long EmpID [], float PayRate [], int size) {
	int i;

	for (i=0; i<size; i++){
		cout<<"Employee"<<" "<< EmpID [i]<< "pay rate:"; 
		cin >> PayRate [i]; 

		while (PayRate[i] < 6.00){
			cout<<"Invalid"<<endl;
			cout<<"Employeed"<<" "<<EmpID [i] <<"pay rate:"; 
			cin>> PayRate [i];
		}
	}
}

void getWages (long EmpID[], int Hours[], float PayRate[],float Wages [], int size){
	int i;
	
	for (i=0; i<size; i++)
		Wages[i] = Hours [i] * PayRate [i];
}

void SelectionSort (long EmpID[], float ar [], int size) {
	int x, minIndex, minValue;
	
	for (x = 0; x < (size - 1); x++){
		minIndex = x;
		minValue = ar [x];
		
		for (int index = x + 1; index < size; index++){
			if (ar [index] < minValue){
				minValue = ar[index];
				minIndex = index;
			}
		}
		ar[minIndex] = ar[x];
		ar[x] = minValue; 
	}
}


int main () {
	int amount = 7;
	int x;
	long EmpID[ ]={5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489};
	int Hours [7]; 
	float PayRate [7];
	float Wages [7];
	
	SearchList (EmpID,Wages,amount);

	getHours (EmpID, Hours, amount);
	getPayRate (EmpID, PayRate, amount);
	getWages (EmpID,Hours,PayRate,Wages,amount);

	SelectionSort(EmpID, Wages, amount);

	for (x=0; x < amount; x++)
		cout<<"Employee"<<" "<< EmpID [x]<< "your total is" << Wages [x]<<endl;

	return 0;
}

Topic archived. No new replies allowed.