Loop closes before finishing

Hey this is my first post and was wondering if anyone could help me.
I'm writing a code that's suppose to do a payroll for my intro cs class.
At first it was working fine until I had to add the part that made sure a user couldn't enter a wage value below $6.00 and now it stops the loop right after that part for some reason. Any help would be appreciated.
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
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
int const HR = 7;
int const wage = 7, gross = 7, hour =7;
int empid[HR] = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489};
double hours[hour];
double payrate[wage];
double wages[gross];


cout << "This program calculates the wages for employees\n";

for (int count = 0; count < HR; count++)
{
	double grossPay;
	double WAGE = 6.00;
	cout << fixed << showpoint << setprecision(2);
	cout << "For employee with the I.D. # " << empid[count] << " please type in their hours.\n";
	cin >> hours[count];
	cout << "Now type in the wage for the employee with I.D. # " <<empid[count] << endl;
	cin >> payrate[count];
	if (payrate[count]<WAGE)
	{
		cout << "Please enter wage above $6.00\n";
		cin >> payrate[count];
	}

	cout << "For employee with I.D. # " << empid[count] << " their gross wage is \n";
	cout << "$" << hours[count] * payrate[count] << "."<< endl;
	grossPay = payrate[count] * wages[count];
	while (grossPay = wages[count]);
	cout << "Gross pay for " << empid[count] << " is " << wages[count] << " "<< endl;
}

return 0;
}
1
2
3
4
while (grossPay = wages[count]); // I don't understand what you wanna do here but
// this is an infinite loop (that's where your program "stops")

grossPay = payrate[count] * wages[count]; // wages[count] is uninitialized btw. don't know if intended 
What I was trying to do was implement the output of payrate*wages into the wages[count] array. I wanted to put the input for each variable that pertained to it and now that you mention it was a infinite loop it kind of makes sense because for some reason the program wouldn't end or anything. Btw ty for the help Glandy :D
Last edited on
Topic archived. No new replies allowed.