Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Payroll program needs to be sorted using the exsel sort that I have included

ID: 667549 • Letter: C

Question

C++ Payroll program needs to be sorted using the exsel sort that I have included in my program(it was provided to use, so it has to be in the program), but it won't run. I don't know what is wrong with the program.

#include<fstream>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
const int MAX = 2;
class payroll{
   ifstream fin;
   char employeeid[12];
   char employeename[20];
   char maritalstatus;
   int hoursworked,overtime;
   int numberOfEmployees;
   int totalEmployeeCount;
   char employee;
   int n;
   int i, j;
   double hourlyrate, overtimepay, regularpay, hourlygrosspay, salarygrosspay, taxrate, taxamount, netpay, averagenetpay;
   void calculatehourlygrosspay();
   void calculatesalarygrosspay();
   void calculatehourlytax();
   void calculatesalarytax();
   void calculatehourlynetpay();
   void calculatesalarynetpay();
   void calculateaveragenetpay();
   void sortNetPayUsingExselSort();
   int printheader();
   void printdata();
public: payroll();
   ~payroll();
   void printreport(); };
payroll::payroll(){
   fin.open("payroll.txt");}//CONSTRUCTOR
   payroll::~payroll(){
   fin.close(); }//DESTRUCTOR
   void payroll::calculatehourlygrosspay(){
       if(hoursworked > 40){
           overtime = hoursworked - 40;
           regularpay = hoursworked * hourlyrate;
           overtimepay = overtime * (hourlyrate * 1.5);
           hourlygrosspay = regularpay + overtimepay; }//IF   
else hourlygrosspay = hoursworked * hourlyrate; }//CALCULATEGROSSPAY
void payroll ::calculatehourlytax(){
if (hourlygrosspay >= 500) taxrate = .20;
   else if(hourlygrosspay > 200.00) taxrate = .20;
   else taxrate = .10;
   if(maritalstatus == 'S'|| maritalstatus=='s')
           taxrate = taxrate + .05;
   taxamount = hourlygrosspay * taxrate; }//CALCULATETAX
void payroll :: calculatehourlynetpay(){
       netpay = hourlygrosspay - taxamount; }//CALCULATENETPAY
void payroll::calculatesalarygrosspay(){
if(hoursworked>0){   
overtimepay=hoursworked*(regularpay/52/40);
regularpay=hourlyrate/52;
salarygrosspay=regularpay+overtimepay; }//If
else salarygrosspay = hoursworked * hourlyrate; }//CALCULATEGROSSPAY
void payroll ::calculatesalarytax(){
if (salarygrosspay >= 500) taxrate = .20;
   else if(salarygrosspay > 200.00) taxrate = .20;
   else taxrate = .10;
   if(maritalstatus == 'S'|| maritalstatus=='s')
           taxrate = taxrate + .05;
   taxamount = salarygrosspay * taxrate; }//CALCULATETAX
void payroll :: calculatesalarynetpay(){
       netpay = salarygrosspay - taxamount; }//CALCULATENETPAY      
void payroll :: calculateaveragenetpay(){
averagenetpay=netpay / 2; }//CALCULATEAVERAGENETPAY
//Sort the employee object array in ascending
int printHeader(); //call function to print the header
char employee[0], printData(); //print the first element of employee object array
int i, j;
int totalEmployeeCount();
//initial loop to the netPay array
for ( i = 1; i < totalEmployeeCount; i++ ){
//second loop to actual values
for ( j = 0; j < totalEmployeeCount - i; j++ ){
if ( employee[j]->netPay > employee[j+1]->netPay )
payroll * temp;
//do the actual swap
temp = employee[j];
employee[j] = employee[j+1];
employee[j+1] = temp;
} //end if
}//end for loop
} //end for loop
==========
void sortNetPayUsingExselSort(employee * employees[], int numberOfEmployees)
{
int lower, upper, sortflag = 0, sml = 0, scan = 0;
lower = 0;
upper = numberOfEmployees - 1;
while( (lower < upper) && (sortflag == 1) )
{
   sml = lower;
sortflag = 0;
scan = lower + 1;
   while (scan <= upper - ...)
{
if( employees[scan]->getNetPay() > employees[scan + 1]->getNetPay() )
{
   swap(employees, scan, scan + 1);
   sortflag = ...;
if( employees[scan]->getNetPay() < employees[sml]->...)
{
sml = scan;
}
}
   scan++;
} // while
    swap(employees, lower, sml);
upper = upper - 1;
lower = lower + ...;
} // while
void payroll::printdata(){
       cout<        cout<        <        < void payroll::printreport(){
       int i = 0;
       printheadings();
       while(fin>>employeename>>employeeid>>maritalstatus>>hoursworked>>hourlyrate){
           calculatehourlygrosspay();
           calculatesalarygrosspay();
           calculatehourlytax();
           calculatesalarytax();
           calculatehourlynetpay();
           calculatesalarynetpay();
           calculateaveragenetpay();
           sortNetPayUsingExselSort();
           printdata();
           i++; }//WHILE
       }//PRINTREPORT
int main(){
       payroll employee;
       employee.printreport(); }//MAIN

I keep getting the error:

75   4 [Error] expected unqualified-id before 'for'

75   17[Error] 'i' does not name a type

75   41[Error] 'i' does not name a type

86   4[Error] expected declaration before '}' token

Explanation / Answer

75 4 [Error] expected unqualified-id before 'for'

This error is because for is outside the function

86 4[Error] expected declaration before '}' token

you have to remove ; int totalEmployeeCount(); from this line

#include<fstream>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
const int MAX = 2;
class payroll{
ifstream fin;
char employeeid[12];
char employeename[20];
char maritalstatus;
int hoursworked,overtime;
int numberOfEmployees;
int totalEmployeeCount;
char employee;
int n;
int i, j;
double hourlyrate, overtimepay, regularpay, hourlygrosspay, salarygrosspay, taxrate, taxamount, netpay, averagenetpay;
void calculatehourlygrosspay();
void calculatesalarygrosspay();
void calculatehourlytax();
void calculatesalarytax();
void calculatehourlynetpay();
void calculatesalarynetpay();
void calculateaveragenetpay();
void sortNetPayUsingExselSort();
int printheader();
void printdata();
public: payroll();
~payroll();
void printreport(); };
payroll::payroll(){
fin.open("payroll.txt");}//CONSTRUCTOR
payroll::~payroll(){
fin.close(); }//DESTRUCTOR
void payroll::calculatehourlygrosspay(){
if(hoursworked > 40){
overtime = hoursworked - 40;
regularpay = hoursworked * hourlyrate;
overtimepay = overtime * (hourlyrate * 1.5);
hourlygrosspay = regularpay + overtimepay; }//IF   
else hourlygrosspay = hoursworked * hourlyrate; }//CALCULATEGROSSPAY
void payroll ::calculatehourlytax(){
if (hourlygrosspay >= 500) taxrate = .20;
else if(hourlygrosspay > 200.00) taxrate = .20;
else taxrate = .10;
if(maritalstatus == 'S'|| maritalstatus=='s')
taxrate = taxrate + .05;
taxamount = hourlygrosspay * taxrate; }//CALCULATETAX
void payroll :: calculatehourlynetpay(){
netpay = hourlygrosspay - taxamount; }//CALCULATENETPAY
void payroll::calculatesalarygrosspay(){
if(hoursworked>0){   
overtimepay=hoursworked*(regularpay/52/40);
regularpay=hourlyrate/52;
salarygrosspay=regularpay+overtimepay; }//If
else salarygrosspay = hoursworked * hourlyrate; }//CALCULATEGROSSPAY
void payroll ::calculatesalarytax(){
if (salarygrosspay >= 500) taxrate = .20;
else if(salarygrosspay > 200.00) taxrate = .20;
else taxrate = .10;
if(maritalstatus == 'S'|| maritalstatus=='s')
taxrate = taxrate + .05;
taxamount = salarygrosspay * taxrate; }//CALCULATETAX
void payroll :: calculatesalarynetpay(){
netpay = salarygrosspay - taxamount; }//CALCULATENETPAY
void payroll :: calculateaveragenetpay(){
averagenetpay=netpay / 2; }//CALCULATEAVERAGENETPAY
//Sort the employee object array in ascending
int printHeader(); //call function to print the header
char employee[0], printData(); //print the first element of employee object array
int i, j;
int totalEmployeeCount()
//initial loop to the netPay array
{
  
for ( i = 1; i < totalEmployeeCount; i++ ){
//second loop to actual values
for ( j = 0; j < totalEmployeeCount - i; j++ ){
if ( employee[j]->netPay > employee[j+1]->netPay )
payroll * temp;
//do the actual swap
temp = employee[j];
employee[j] = employee[j+1];
employee[j+1] = temp;
} //end if
}//end for loop
}
}//end for loop
==========
void sortNetPayUsingExselSort(employee * employees[], int numberOfEmployees)
{
int lower, upper, sortflag = 0, sml = 0, scan = 0;
lower = 0;
upper = numberOfEmployees - 1;
while( (lower < upper) && (sortflag == 1) )
{
sml = lower;
sortflag = 0;
scan = lower + 1;
while (scan <= upper - ...)
{
if( employees[scan]->getNetPay() > employees[scan + 1]->getNetPay() )
{
swap(employees, scan, scan + 1);
sortflag = ...;
if( employees[scan]->getNetPay() < employees[sml]->...)
{
sml = scan;
}
}
scan++;
} // while
swap(employees, lower, sml);
upper = upper - 1;
lower = lower + ...;
} // while
void payroll::printdata(){
cout< cout< < < void payroll::printreport(){
int i = 0;
printheadings();
while(fin>>employeename>>employeeid>>maritalstatus>>hoursworked>>hourlyrate){
calculatehourlygrosspay();
calculatesalarygrosspay();
calculatehourlytax();
calculatesalarytax();
calculatehourlynetpay();
calculatesalarynetpay();
calculateaveragenetpay();
sortNetPayUsingExselSort();
printdata();
i++; }//WHILE
}//PRINTREPORT
int main(){
payroll employee;
employee.printreport(); }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote