Please examine the C++ code and make corrections please.   ##include using namespace std;     //employee class class Employee { private:     //fields     string name, address, phone;     double payRate;     public:       //cosntructors     Employee() {}       Employee(string n, string a, double p, string ph)     {         name = n;         address = a;         payRate = p;         phone = p;     }         //accessors     string getName() { return name; }     string getAddress() { return address; }     string getPhone() { return phone; }     double getPayRate() { return payRate; }         //setters     void setName(string n)     {         name = n;     }       void setAddress(string a) { address = a; }     void setPhone(string ph) { phone = ph; }     void setPayRate(double pr) { payRate = pr; } };       //employee directory class class EmployeeDirectory { private:     //all employees are added into this vector     vector employees;   public:     EmployeeDirectory() {}         //this function adds a new employee     void addEmployee(string n, string a, double p, string ph)     {         //make employee object and add in vector         Employee e(n, a, p, ph);         employees.push_back(e);     }         //this function returns Employee object for the name searched     Employee searchByName(string n)     {         //iterate all employees         for (Employee e : employees)         {             //if name matches with given name then return the employee object             if (e.getName() == n)                 return e;         }             //if employee not found, make an empty employee object and send         Employee e;         return e;     }         //prints all the employees, only names as given in question     void displayAll()     {         cout << "All employees are : " << endl;           for (Employee e : employees)         {             cout << e.getName() << endl;         }           cout << endl;     } };     int main() {     cout << "Everest Law  This is CSC CSC 102 Final Exam - Employee Directory\n";     cout << "\n";       EmployeeDirectory directory;       directory.addEmployee("Sarah Paulson", "1769 Polly Fork, West Nyasia, South Dakota", 1920, "(138) 705 9405");     directory.addEmployee("Tom Holland", "1769 Polly Fork, West Nyasia, South Dakota", 2500, "(991) 201 9415");     directory.addEmployee("Emma Watson", "1769 Polly Fork, West Nyasia, South Dakota", 2000, "(532) 427 2850");     directory.addEmployee("Leonardo Dicaprio", "1769 Polly Fork, West Nyasia, South Dakota", 4580, "(904) 188 3811");     directory.addEmployee("Maggie Smith", "1769 Polly Fork, West Nyasia, South Dakota", 1900, "(049) 737 8587");       directory.displayAll(); }

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

Please examine the C++ code and make corrections please.

 

##include<bits / stdc++.h>

using namespace std;

 

 

//employee class

class Employee

{

private:

    //fields

    string name, address, phone;

    double payRate;

 

 

public:

 

    //cosntructors

    Employee() {}

 

    Employee(string n, string a, double p, string ph)

    {

        name = n;

        address = a;

        payRate = p;

        phone = p;

    }

 

 

    //accessors

    string getName() { return name; }

    string getAddress() { return address; }

    string getPhone() { return phone; }

    double getPayRate() { return payRate; }

 

 

    //setters

    void setName(string n)

    {

        name = n;

    }

 

    void setAddress(string a) { address = a; }

    void setPhone(string ph) { phone = ph; }

    void setPayRate(double pr) { payRate = pr; }

};

 

 

 

//employee directory class

class EmployeeDirectory

{

private:

    //all employees are added into this vector

    vector<Employee> employees;

 

public:

    EmployeeDirectory() {}

 

 

    //this function adds a new employee

    void addEmployee(string n, string a, double p, string ph)

    {

        //make employee object and add in vector

        Employee e(n, a, p, ph);

        employees.push_back(e);

    }

 

 

    //this function returns Employee object for the name searched

    Employee searchByName(string n)

    {

        //iterate all employees

        for (Employee e : employees)

        {

            //if name matches with given name then return the employee object

            if (e.getName() == n)

                return e;

        }

 

 

        //if employee not found, make an empty employee object and send

        Employee e;

        return e;

    }

 

 

    //prints all the employees, only names as given in question

    void displayAll()

    {

        cout << "All employees are : " << endl;

 

        for (Employee e : employees)

        {

            cout << e.getName() << endl;

        }

 

        cout << endl;

    }

};

 

 

int main()

{

    cout << "Everest Law  This is CSC CSC 102 Final Exam - Employee Directory\n";

    cout << "\n";

 

    EmployeeDirectory directory;

 

    directory.addEmployee("Sarah Paulson", "1769 Polly Fork, West Nyasia, South Dakota", 1920, "(138) 705 9405");

    directory.addEmployee("Tom Holland", "1769 Polly Fork, West Nyasia, South Dakota", 2500, "(991) 201 9415");

    directory.addEmployee("Emma Watson", "1769 Polly Fork, West Nyasia, South Dakota", 2000, "(532) 427 2850");

    directory.addEmployee("Leonardo Dicaprio", "1769 Polly Fork, West Nyasia, South Dakota", 4580, "(904) 188 3811");

    directory.addEmployee("Maggie Smith", "1769 Polly Fork, West Nyasia, South Dakota", 1900, "(049) 737 8587");

 

    directory.displayAll();

}

Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE 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