INSTRUCTIONS: COMPLETE THE FOLLOWING QUESTION USING VISUAL STUDIO Design a class
ID: 3862716 • Letter: I
Question
INSTRUCTIONS: COMPLETE THE FOLLOWING QUESTION USING VISUAL STUDIO
Design a class called employee with the following private data members:
name (string)
job title (string e.g., manager, accountant, etc.)
id (int)
salary (double)
department (string e.g., production, marketing, etc.)
The class should have member functions to set and get each private data member as well as a default constructor.
Use this class to write a small C++program that creates three instances/objects of employee, initializing each object data on some user-supplied values and displaying data of each object. The program should also increase salary of each employee by 10% and then display updated data of each employee.
Place the class within a header file called Employee.h and the member functions in another file called Employee.cpp. Save the project as your first name
Grading will be based on the usual rubric
Explanation / Answer
#include <iostream>
using namespace std;
class Student
{
private: // private data member
int id;
char *name;
char *jobTitle;
char *department;
double salary;
public: // public accessor and mutator functions
int getid()
{
return id;
}
void setid(int sI)
{
id=sI;
}
int getname()
{
return *name;
}
void setname(char *sName)
{
*name=*sName;
}
int getjobTitle()
{
return *jobTitle;
}
void setjobTitle(int sJobTitle[])
{
*jobTitle=*sJobTitle;
}
int getdepartment()
{
return *department;
}
void setdepartment(char sDepartment[])
{
*department=*sDepartment;
}
int getsalary()
{
return salary;
}
void setsalary(int sSalary)
{
salary=sSalary;
}
};
int main()
{
Student A;
Student B;
Student C;
A.setid(1);
B.setid(1);
C.setid(1);
A.setname("Allo");
B.setname("Bllo");
C.setname("Cllo");
A.setdepartment("IT");
B.setdepartment("ME");
C.setdepartment("EN");
A.setsalary(1000000.00);
B.setsalary(100000.00);
C.setsalary(10000.00);
cout<<A.getsalary();//Print acordingly all the values
}
For the other class there is just need to create function that increment value by 10%
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.