Use an IDE to create and compile a basic program. Please follow the description below.

profilesmitty4eva
cs115_unit5_sample_code.txt

// Use of Classes and dynamic allocation #include <iostream> using namespace std; // Employee class definition class Employee { private: string empName; string empAddress; string empEmail; int vacationMonths; int * empVacationDays; // hold vacation days taken for every month public: void setEmpName(string); string getEmpName(); void setEmpAddress(string); string getEmpAddress(); void setEmpEmail(string); string getEmpEmail(); void setEmpVacationDays(int, int); // sets vacation days for a specific month int getEmpVacationDays(int); //gets vacation days taken in a specific month int getTotalEmpVacationDays(); //gets the total vacation days // Constructor Employee(); Employee(int); // this constructor sets up the size of the emplyee vacation array // Destructor ~Employee(); }; //definition of set/get member functions of Employee class void Employee::setEmpName(string name) { empName=name; } void Employee::setEmpAddress(string address) { empAddress=address; } void Employee::setEmpVacationDays(int month, int vDays) { empVacationDays[month-1]=vDays; } void Employee::setEmpEmail(string email) { empEmail=email; } string Employee::getEmpName() { return empName; } string Employee::getEmpAddress() { return empAddress; } string Employee::getEmpEmail() { return empEmail; } int Employee::getEmpVacationDays(int month) { return empVacationDays[month-1]; } int Employee::getTotalEmpVacationDays() { int sum = 0; for (int i=0; i<12; i++) sum += empVacationDays[i]; return sum; } // Constructor 1 definition Employee::Employee() { empName = ""; empAddress = ""; empEmail=""; vacationMonths = 12; empVacationDays = new int [vacationMonths]; for (int i=0; i<vacationMonths; i++) empVacationDays[i] = 0; } // Constructor 2 definition Employee::Employee(int months) { empName = ""; empAddress = ""; empEmail=""; vacationMonths = months; empVacationDays = new int [months]; for (int i=0; i<vacationMonths; i++) empVacationDays[i] = 0; } // Destructor definition Employee::~Employee() { delete [] empVacationDays; // de-allocating the array space before object is deleted } void displayMenu(Employee *emp) { cout << emp->getEmpName() << ", please select an action from the menu below" << endl; cout<<"My Menu"; cout<<"========" << endl; cout<<"1 - View My Address" << endl; cout<<"2 - View My Email Address" << endl; cout<<"3 - View Total Vacation Days Taken" << endl; cout<<"4 - View Vacation Days Taken in Specific Month" << endl; cout<<"X - Exit " <<endl<<endl; } // View address for <name> void viewAddress(Employee *emp) { cout << "Name: " << emp->getEmpName() << endl; cout << "Address: " << emp->getEmpAddress() << endl; } // View email address for <name> void viewEmail(Employee *emp) { cout << "Name: " << emp->getEmpName() << endl; cout << "Email Address: " << emp->getEmpEmail()<< endl; } // returns total vacation days taken for <name> int totalVacationDays(Employee *emp) { return emp->getTotalEmpVacationDays(); } // returns vacation days taken for a specific month for <name> int vacationDaysMonth(Employee *emp, int month) { return emp->getEmpVacationDays(month); } int main(void) { // variable declaration section char selection = ' '; string * months; months = new string[12]; // dynamic allocation months[0] = "Jan"; months[1] = "Feb"; months[2] = "Mar"; months[3] = "Apr"; months[4] = "May"; months[5] = "Jun"; months[6] = "Jul"; months[7] = "Aug"; months[8] = "Sep"; months[9] = "Oct"; months[10] = "Noc"; months[11] = "Dev"; Employee * employee1; employee1 = new Employee(); // dynamic allocation //Initialize employee1 members employee1->setEmpName("John Smith"); employee1->setEmpAddress("1235 Main Street"); employee1->setEmpEmail("[email protected]"); employee1->setEmpVacationDays(1, 2); // 2 vacation days taken in the month of January employee1->setEmpVacationDays(7, 8); // 8 vacation days taken in the month of July //display employee name cout << "Hello "+ employee1->getEmpName() << endl; do { // display menu displayMenu(employee1); // read user selection cin>>selection; switch(selection) { case '1': cout<< "View My Address is selected" << endl; viewAddress(employee1); break; case '2': cout<< "View My Email Address is selected" << endl; viewEmail(employee1); break; case '3': cout<< "View Total Vacation Days Taken is selected" << endl; cout << "You have taken " << totalVacationDays(employee1) << " days!!" << endl; break; case '4': cout<< "View Total Vacation Days Taken for Specific Month is selected" << endl; cout << "Enter month => "; int month; cin >> month; cout << "You have taken " << vacationDaysMonth(employee1, month) << " days in month of " << months[month-1] << endl; break; case 'X' : case 'x': cout<<"Thank you!!!" << endl; break; // other than 1, 2, 3 and X... default : cout<<"Invalid selection. Please try again"; // no break in the default case } cout<<endl<<endl; } while (selection!= 'X' && selection != 'x'); delete [] months; // release allocated memory for array months return 0; }