t employees by rate of pay from high to low. •returns the average earnings of all employees •performs the search for a specific employee and returns the employee ID if found and 0 if not. •test the functions in the main function   #include #include #include using name

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with:

•sort employees by rate of pay from high to low.

•returns the average earnings of all employees

•performs the search for a specific employee and returns the employee ID if found and 0 if not.

•test the functions in the main function

 

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

 

class Employee

{

private:

int    empNumber;  // Employee number

string name;       // Employee name

double hours,      // Hours worked

payRate;    // Hourly pay rate

public:

Employee(int empN, string n, double h, double p)

{

empNumber = empN;

name = n;

hours = h;

payRate = p;

}

 

Employee()

{

empNumber = 0;

name = "No Name";

hours = 0;

payRate = 0;

}

void setEmpNumber(int number)

{

empNumber = number;

}

 

void setName(string n)

{

name = n;

}

 

void setPayRate(double rate)

{

payRate = rate;

}

 

void setHours(double h)

{

hours = h;

}

 

int getEmpNumber()

{

return empNumber;

}

 

string getName()

{

return name;

}

 

double getHours()

{

return hours;

}

 

double getPayRate()

{

return payRate;

}

 

double getWage()

{

return payRate * hours;

}

 

string getEmpData()

{

string data = "\nEmployee ID Number ===> " + to_string(empNumber);

data += "\nEmployee Name ========> " + name;

data += "\nHours Worked =========> " + to_string(hours);

data += "\nPay Rate =============> " + to_string(payRate);

data += "\nTotal Wage ===========> " + to_string(getWage());

data += "\n";

 

return data;

}

 

};

 

Employee findHigh(Employee list[], int size)

{

 

Employee high = list[0];

for (int i = 0; i < size; i++)

if (list[i].getWage() > high.getWage())

{

high = list[i];

}

return high;

}

 

Employee findLow(Employee list[], int size)

{

 

Employee low = list[0];

for (int i = 0; i < size; i++)

if (list[i].getWage() < low.getWage())

{

low = list[i];

}

return low;

}

 

void sortEmployeesAZ(Employee list[], int size)

{

Employee emp;

for (int i = 0; i < size - 1; i++)

for (int j = i + 1; j < size; j++)

if (list[i].getName() > list[j].getName())

{

emp = list[i];

list[i] = list[j];

list[j] = emp;

}

}

 

void printList(Employee list[], int size){

    for (int i = 0; i < size; i++)

{

cout << list[i].getEmpData();

}

}

 

//sort employees by rate of pay from high to low.

void sortEmployeesHighLowRate(Employee list[], int size)

{

    //put code here

}

 

// here, code returns of the average earnings of all employees 

double averageWage(Employee list[], int size)

{

    //code hereee

    return 0;

}

// code something that performs the search for a specific employee and returns the employee ID if found and 0 if not. 

int findEmployeeById(Employee list[], int size, int myId)

{

    //code

    return 0;

}

 

int main()

{

const int NUM_EMPLOYEES = 4;

 

Employee list[NUM_EMPLOYEES];

list[0] = Employee(1, "John", 40, 25);

list[1] = Employee(2, "Mary", 30, 40);

list[2] = Employee(3, "Grace", 35, 30);

list[3] = Employee(4, "Mark", 45, 20);

 

Employee x = findLow(list, NUM_EMPLOYEES);

std::cout << "Lowest wage:" << x.getEmpData() << std::endl;

    x = findHigh(list, NUM_EMPLOYEES);

std::cout << "Highest wage:" << x.getEmpData() << std::endl;

 

printList(list, NUM_EMPLOYEES);

 

sortEmployeesAZ(list, NUM_EMPLOYEES);

 

cout << "\n++++++++++++++ Sorted by name ++++++++++++++++++++" << endl;

 

printList(list, NUM_EMPLOYEES);

 

//and here is testing code 

 

 

 

 

 

 

/////////////////////////////////

 

return 0;

}

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education