rendered paste bodyvoid comNew()
{
int storeNumber;
char firstName[20];
char lastName[20];
double hourlyRate, hoursWorked;
cin >> storeNumber >> firstName >> lastName >> hourlyRate >> hoursWorked;
if(cin.fail())
{
recenterror = 1;
}
else
{
char name[20];
int i = 0;
int j = 0;
strcpy(name, firstName);
while(name[j] != NULL)
{
j++;
}
name[j] = ' ';
j++;
while(lastName[i] != NULL)
{
name[j] = lastName[i];
i++;
j++;
}
name[j] = NULL;
stores[storeNumber].addEmployee(name, hourlyRate, hoursWorked);
}
}
void
Staff::addEmployee (char * _name, double _hourlyRate, double _hours)
{
int j = 0;
for(j; j < this->totalEmployees; j++);
(this->employees[j]).setName(_name);
(this->employees[j]).setHourlyRate(_hourlyRate);
(this->employees[j]).setHours(_hours);
(this->totalEmployees)++;
cout << "New: OK\n";
}
void Employee::printPayroll ()
{
double normalHours, overtimeHours, grossPay, taxAmount, netPay, taxMultiplyer,
taxMuliplyer = taxRate();
if (this->hours > 40)
{
overtimeHours = this->hours - 40;
normalHours = this->hours - overtimeHours;
}
else
{
normalHours = this->hours;
overtimeHours = 0;
}
grossPay = (normalHours * this->hourlyRate) + (overtimeHours * this->hourlyRate * 1.5);
taxAmount = grossPay * taxMultiplyer;
netPay = grossPay - taxAmount;
cout << (this->name) << ": " <<grossPay << " - " << taxAmount << " = " << netPay << endl;
// Print the "payroll" output line for this employee
}