Answer to Question #299600 in C++ for Ahmad

Question #299600

You are going to make an employee management system. In this lab, you have to create




an Employee class only. Employee class fields are: Employee Name, Employee ID, and Employee Gender. The member functions include the getters and setters for all the member variables and display () function to display the data. In the main function, first create two Employee objects and allow the user to enter data in these objects. Secondly, display the data from these objects.

1
Expert's answer
2022-02-19T02:40:22-0500
#include <iostream>
using namespace std;

class employee {
private:
  string name;
  int id;
  string gender;
public:
  void set_name(string name) {
    this->name = name;
  }
  string get_name() {
    return name;
  }
  void set_id(int id) {
    this->id = id;
  }
  int get_id() {
    return id;
  }
  void set_gender(string gender) {
    this->gender = gender;
  }
  string get_gender() {
    return gender;
  }
  void display() {
    cout << "name: " << name << "\n" 
         << "id: " << id << "\n"
         << "gender: " << gender << "\n";
  }
}

int main() {
  string name, gender;
  int id;
  cout << "name: "; cin >> name;
  cout << "id: "; cin >> id;
  cout << "gender: "; cin >> gender;

  employee emp;
  emp.set_name(name);
  emp.set_id(id);
  emp.set_gender(gender);
  emp.display();

  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog