Question: After you have submitted you Project-1 database, make a copy and using the copy put the class in a file and save as header file

After you have submitted you "Project-1 database", make a copy and using the copy put the class in a file and save as header file (.h). Keep the main program in a cpp file. Write an include statent in your main program. When they are in same directory, and you have cpp file open, they should compile and run. MAKE SURE THIS WORKS before you submit Submit both files. !!!THIS IS ALL IN C++!!! DOWN BELOW IS MY "Project-1 database" PLEASE LET ME KNOW WHAT EXACTLY I NEED TO DO AND DO THE INCLUDE STATMENT FOR THE MAIN PROGRAM IT IS TALKING ABOUT, THANK YOU!

#include

#include

using namespace std;

class Employee

{

private:

string name;

int hiredYear;

int yearsWorked;

double salary;

public:

Employee(string e_name, int e_hiredYear, double e_sal)

{

name = e_name;

hiredYear = e_hiredYear;

salary = e_sal;

time_t t = time(NULL);

tm* timePtr = localtime(&t);

yearsWorked = (1900 + timePtr->tm_year )- hiredYear;

}

void setName(string e_name)

{

name = e_name;

}

void setSalary(double e_sal)

{

salary = e_sal;

}

void setHiredYear(int years)

{

hiredYear = years;

time_t t = time(NULL);

tm* timePtr = localtime(&t);

yearsWorked = (1900 + timePtr->tm_year) - years;

}

string getName()

{

return name;

}

double getSalary()

{

return salary;

}

int getYearsWorked()

{

return yearsWorked;

}

int getHiredYear()

{

return hiredYear;

}

void print()

{

cout<<" Name="<

{"Sheela Dixit", 1999, 6000},

{"Leena Barman", 2005, 3700},

{"James Moriairty", 2010, 2000},

{"John Watson", 1989, 8000}};

while(true)

{

cout<<"1. Print a record 2. Print all records 3. Update a record 4. Exit";

cout<<" Enter your choice: ";

cin>>choice;

switch(choice)

{

case 1: cout<<" Select a record(1-5): ";

cin>>recordNum;

if(recordNum>0 && recordNum <= 5)

employees[recordNum-1].print();

break;

case 2: for(int i=0; i<5; i++)

{

employees[i].print();

}

break;

case 3: cout<<" Select a record(1-5): ";

cin>>recordNum;

if(recordNum>0 && recordNum <= 5)

{

cout<<" 1. Update Name 2. Update salary 3. Update hired year";

cout<<" Enter your choice: ";

cin>>updateChoice;

if(updateChoice == 1)

{

cout<<"Enter the new name: ";

cin>>name;

employees[recordNum-1].setName(name);

}

else if(updateChoice == 2)

{

cout<<"Enter the new salary: ";

cin>>sal;

employees[recordNum-1].setSalary(sal);

}

else if(updateChoice == 3)

{

cout<<"Enter the new hired year: ";

cin>>hiredyear;

employees[recordNum-1].setHiredYear(hiredyear);

}

}

break;

case 4: exit(0);

}

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!