Question
I need help coding my main function of my C++ program assignment. Use of vectors not allowed. My code currently compiles. Please compile solution first
I need help coding my main function of my C++ program assignment.
Use of vectors not allowed. My code currently compiles. Please compile solution first before posting. Rating helpful solution thumbs up!
Required output with explanation on the side notes(includes data files content):
Side note:
Both files will already be sorted in alphabetical order (according to the last name). You must output to the screen all of the employees, their SSNs, and their yearly pay such that they are in alphabetical order according to their last names.
We are hinted to use substr, find, stod, rfind from string header and isdigit from cctype header.
My code. I believe classes and functions are correct. I just need help with main function, reading the two files and having correct output. :
#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; };
//inherit from from employee, publicly 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; };
//inhert from employee, publicly class faculty: public employee //1 double 3 func { public: double get_yearly_pay(); void set_yearlysalary(double); void set_name(string);
private: double yearlysalary; };
//EMPLOYEE CLASS FUNCTIONS 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 9) { ssn = "000-00-0000"; } else { ssn = ans; } } //EMPLOYEE CLASS FUNCTIONS
//STAFF CLASS FUNCTIONS double staff::get_yearly_pay() { if(hoursperweek
void staff::set_hourlypayrate(double hourlypayrate) { this->hourlypayrate = hourlypayrate; }
void staff::set_hoursperweek(double hoursperweek) { this->hoursperweek = hoursperweek; } //STAFF CLASS FUNCTIONS
//FACULTY CLASS FUNCTIONS 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; }
//FACULTY CLASS FUNCTIONS
int main(int __attribute__((unused)) argc, char **argv) { //read in two files provided at the command line // staff s; faculty f;
string line;
ifstream infile(argv[1]); ifstream infile2(argv[2]); //STAFF //ssn //hourly pay //hours worked while (getline(infile, line)) { /*istringstream iss(line); for (int i = 0; i
} infile.close(); //FACULTY /ame //ssn //hourly pay //hours worked
while (getline(infile2, line)) { /*istringstream iss(line); //for (int i = 0; i
} infile2.close();
return 0;
}
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 @bobby 05]$ cat staff Albert Einstein 555-66-7777 10 40 Albert Finstein <. start of new loop albert david johnson name ssn pay worked a function get_yearly_pay should exist which returns the employee yearly if number hours per week is less than it calculated as weeks hourly rate. weekly over then they get their normal rate for those and this be reflected in output. cat faculty big biggie bob grillie faculty: dr. ssn: pay: staff: einstein finstein c--ssn salary . staff bobby that read may invalid more digits or valid but contain non-digits. anything with nine example are both not valid. setter store having dashes regardless were present input not. set to>Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started