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

Circle and correct all syntax errors and logic error in following code include <

ID: 3799602 • Letter: C

Question

Circle and correct all syntax errors and logic error in following code

include <iostream>

using namespace std

Class Employee{ public

// friend functions

friend boolean equal(const Employee& e1, const Employee e2);

// return true if two employees have the same id; false otherwise

friend istream& operator >> (istream& ins, Employee e);

// input e’s id and salary from istream ins

friend ostream& operator << (ostream& outs, const Employee& e);

// output e’s id and salary

// constructors

employee();

// initialize id to be 0 and salary to be 0.0

Employee(int id);

// initialize id to be given id and salary to be 0.0

Employee(int id, double salary);

// initialize id to be given id and salary to be given salary

// member functions

int get_id();

double get_salary();

void set_id(int id);

   void set_salary(double salary);

private:

int _id;

double _salary;

}

int main() {

   Employee employee1(1000, 23000.00);

   Employee employee2;

   cout << "Enter the information of the employee, id and salary, seperated by white space: ";

   cin >> employee2;

   cout << "The employee1's salary is $" << employee1.get_salary();

   if(equal(employee1, employee2))

       cout << "Two emplotees are the same guy.";

   else

       cout << "Two employees are different guys";

   return 0;

}

bool Employee::equal(constant Employee& e1, constant Employee e2) {

      return e1._id == e2._id;

}

istream& operator >> (istream& ins, Employee& e) {

      ins >> e.id;

      ins >> e.salary;

      return ins;

}

ostream& operator >> (ostream& outs, const Employee& e) {

      outs << "ID: " << e._id << ", Salary: " << e._salary;

}

// constructors

Employee::Employee():_id(0);_salary(0.0) {}

Employee::Employee(int id) {

   _id = id;

   _salary = 0.0;

}

Employee::Employee(int id, double salary)

{

   id = _id;

   salary = 0.0;

}

//member function

int Employee::get_id() {

   return _id;

}

double Employee::get_salary() {

   return _salary;

}

void set_id(int id) {

   _id = id;

}

void Employee::set_salary(double salary) {

   _salary = salary;

}

Explanation / Answer

include <iostream>

using namespace std

Class Employee{ public

// friend functions

friend boolean equal(const Employee& e1, const Employee e2);

// return true if two employees have the same id; false otherwise

friend istream& operator >> (istream& ins, Employee e);

// input e’s id and salary from istream ins

friend ostream& operator << (ostream& outs, const Employee& e);

// output e’s id and salary

// constructors

employee();

// initialize id to be 0 and salary to be 0.0

Employee(int id);

// initialize id to be given id and salary to be 0.0

Employee(int id, double salary);

// initialize id to be given id and salary to be given salary

// member functions

int get_id();

double get_salary();

void set_id(int id);

   void set_salary(double salary);

private:

int _id;

double _salary;

}

int main() {

   Employee employee1(1000, 23000.00);

   Employee employee2;

   cout << "Enter the information of the employee, id and salary, seperated by white space: ";

   cin >> employee2;

   cout << "The employee1's salary is $" << employee1.get_salary();

   if(equal(employee1, employee2))

       cout << "Two emplotees are the same guy.";

   else

       cout << "Two employees are different guys";

   return 0;

}

bool Employee::equal(constant Employee& e1, constant Employee e2) {

      return e1._id == e2._id;

}

istream& operator >> (istream& ins, Employee& e) {

      ins >> e.id;

      ins >> e.salary;

      return ins;

}

ostream& operator >> (ostream& outs, const Employee& e) {

      outs << "ID: " << e._id << ", Salary: " << e._salary;

}

// constructors

Employee::Employee():_id(0);_salary(0.0) {}

Employee::Employee(int id) {

   _id = id;

   _salary = 0.0;

}

Employee::Employee(int id, double salary)

{

   id = _id;

   salary = 0.0;

}

//member function

int Employee::get_id() {

   return _id;

}

double Employee::get_salary() {

   return _salary;

}

void set_id(int id) {

   _id = id;

}

void Employee::set_salary(double salary) {

   _salary = salary;

}

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