I need some help with this. I am running through some payroll data. I have run a function that reads a .txt file, and then stores it in arrays. I am now trying to write a function that allows you to add to those arrays (they are arrays of 32 but only have 20 elements from the file) So it needs to loop through the arrays, make sure they do not go out of bounds, and then add the additional data types to the arrays. Here is how it looks for me. There are no errors, but when i run it, it does nothing:
string AddPayrollData(array<double, kMaxSize> &hours,
array<char, kMaxSize> &pay_type,
array<double, kMaxSize> &pay_rate,
array<string, kMaxSize> &names,
double hours_worked, char pay_t, double pay_r, string full_name,
int &size )
{
int i = 0;
while (size < kMaxSize && i < size)
{
if (hours[i] > 168)
{
cout << "Hours is out of range, set to 0" << endl;
hours[i] = 0;
}
if (pay_type[i] != 'h' || 's')
{
cout << "Incorrect pay type, set to s " << endl;
pay_type[i] = 's';
}
if (pay_rate[i] < 7.25)
{
cout << "Pay is less than minimum wage, set to 7.25 " << endl;
pay_rate[i] = 7.25;
}
if (names[i].find(","))
{}
else
{
cout << "Name Is not in last, first format" << endl;
names[size] = "unknown";
}
i++;
}
if(size >= kMaxSize)
{
cout << "Arrays are full, no payroll data added" << endl;
}
else
{
hours_worked = hours[size];
pay_t = pay_type[size];
pay_r = pay_rate[size];
full_name = names[size];
size++;
}
return "";
}
Thanks for the help!
Aucun commentaire:
Enregistrer un commentaire