Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need C++ Help on program. My code posted below. Use of vectors not allowed. Please compile code first. Rating best solution thumbs up! :) Directions:

Need C++ Help on program.

My code posted below. Use of vectors not allowed. Please compile code first. Rating best solution thumbs up! :)

Directions:

image text in transcribedimage text in transcribedimage text in transcribed

Note: We are encouraged to use substr, find, rfind, stod from string, and isdigit from cctype

My code (currently compiles):

#include

#include

#include

#include

using namespace std;

class employee //2 string var 4 func

{

public:

string get_name();

string get_ssn();

void set_name(string);

void set_ssn(string);

protected:

string name;

private:

string ssn;

};

class staff: public employee //2 double var 3 func

{

public:

void set_hourlypayrate(double);

void set_hoursperweek(double);

double get_yearly_pay();

private:

double hourlypayrate;

double hoursperweek;

};

class faculty: public employee //1 double 3 func

{

public:

double get_yearly_pay();

void set_yearlysalary(double);

void set_name(string);

private:

double yearlysalary;

};

string employee::get_name()

{

return name;

}

string employee::get_ssn()

{

return ssn;

}

void employee::set_name(string name)

{

this->name = name;

}

void employee::set_ssn(string ssn)

{

string ans = "";

int count=0;

for(int i = 0; i

{

if(i == 3 || i == 6)

{

ans = ans + '-' + ssn[i];

}

else

{

ans = ans + ssn[i];

}

count++;

}

if(count > 9)

{

ssn = "000-00-0000";

}

else

{

ssn = ans;

}

}

double staff::get_yearly_pay()

{

if(hoursperweek

{

return 52 * hoursperweek * hourlypayrate;

}

else

{

double extra = 52 * 1.5 * hourlypayrate * (hoursperweek - 40);

return extra + 52 * hoursperweek * hourlypayrate;

}

}

void staff::set_hourlypayrate(double hourlypayrate)

{

this->hourlypayrate = hourlypayrate;

}

void staff::set_hoursperweek(double hoursperweek)

{

this->hoursperweek = hoursperweek;

}

double faculty::get_yearly_pay()

{

return yearlysalary;

}

void faculty::set_yearlysalary(double yearlysalary)

{

this->yearlysalary = yearlysalary;

}

void faculty::set_name(string name)

{

employee::set_name(name);

this->name = "Dr. " + this->name;

}

int main(int __attribute__((unused)) argc, char **argv)

{

staff s;

faculty f;

string line;

ifstream infile(argv[1]);

ifstream infile2(argv[2]);

while (getline(infile, line)) //inside staff file

{

/*istringstream iss(line);

cout

}

infile.close();

while (getline(infile2, line)) // inside faculty file

{

}

infile2.close();

return 0;

}

You are to write a program utilizing several classes that will be used to process data and produce reports about employees for a school. The relevant classes are as follows employee: a generic employee class, designed only to hold the employee's name and their social security number (SSN) . The name should be protected, but the SSN should be private. The idea is that the SSN and related functions will never need significant modifications in derived classes, but we may wish to add functionality to how the name is processed, so it would be useful to have more direct access to it. o o Utilize two setter and two getter functions for the name & SSN -- the getter function:s should return a string and the setter functions should take only one parameter each, a string The name that is read in will always contain at least two names, but may have more Only the first & last name should be stored and returned from the getter function o o The SSN that is read in may be invalid (e.g. more/less than 9 digits) or may be valid but contain non-digits. Anything with nine digits is valid, for example 111223333 and 111-22-3333 are both valid, but 1112233334 is not valid. The setter function should store the SSN as having dashes, regardless of if they were present in the input or not. If the SSN read in is invalid, it should be set to 000-00-0000 This class is only allowed to contain two string variables and four functions. o staff: a staff class, which inherits from employee. Use public inheritance . Staff have an hourly pay rate and a number of hours worked per week. Write appropriate separate setter functions for these A function, get yearly pay, should exist which returns the employee's yearly pay. If the number of hours worked per week is less than 40 it is calculated as 52 weeks * hours worked per week * hourly pay rate. If the weekly hours is over 40 then they get 1.5x their normal hourly rate for those hours over 40 hours per week and this should be reflected in the output. This class is only allowed to contain two double variables and three functions o o o . faculty: a faculty class, which inherits from employee. Use public inheritance Staff have a yearly salary which should have a setter function get yearly pay should simply return the salary Override the name setter function from employee so that when the name is set, not only is the employee class setter function called but, when finished, "Dr. " is appended to the beginning of the name This class is only allowed to contain one double variable and three functions. o o o o In your main body you will read in two files provided at the command line. The first file will contain information about staff while the second file will contain information about faculty. You do not have to worry about checking to verify if the arguments are provided or if the files exist - each one exists and contains information about at least one employee but no more than ten

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the importance of Human Resource Management

Answered: 1 week ago

Question

Discuss the scope of Human Resource Management

Answered: 1 week ago