All pastes #354888 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-02-14 05:40 UTC
rendered paste body

void 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::printPayroll ()
{
        if(this->totalEmployees == 0)
        {
                cout << "Error: no employees\n";
        }
        else
        {
                for(int i = 0; i < this->totalEmployees; i++)
                {
                        (this->employees[i]).printPayroll();
                }
        }
        // Print the payroll records for all employees associated with
        // this Staff object
}





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
}