Need help with C++ program. Will rate all helpful solutions! Thank you.. Without
ID: 3722346 • Letter: N
Question
Need help with C++ program. Will rate all helpful solutions! Thank you..
Without using vectors, you are to write a program utilizing several classes that will be used to process data and produce reports about employees for a school.
In the 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. (Need help with main body)
3 Classes (marked off finished and what I need help with):
2 Data Files:
Notes:
My code:
#include <iostream>
#include <string>
#include <fstream>
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 //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 //1 double 3 func
{
public:
double get_yearly_pay();
void set_yearlysalary(double);
void set_name(string);
private:
double yearlysalary;
};
//EMPLOYEE CLASS FUNCTIONS START
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)
{
this->ssn = ssn;
}
//EMPLOYEE CLASS FUNCTIONS END
//STAFF CLASS FUNCTIONS START
double staff::get_yearly_pay()
{
/*
if (hourlypay < 40)
*/
//return hourlypay;
}
void staff::set_hourlypayrate(double hourlypayrate)
{
this->hourlypayrate = hourlypayrate;
}
void staff::set_hoursperweek(double hoursperweek)
{
this->hoursperweek = hoursperweek;
}
//STAFF CLASS FUNCTIONS END
//FACULTY CLASS FUNCTIONS START
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 END
int main(int __attribute__((unused)) argc, char **argv)
{
ifstream infile(argv[2]);
return 0;
}
e employee: a generic employee class, designed only to hold the employee's name and their social security number (SSN). have mere direct access to it._ o Utilize twe setter-and twe-getter funetions forthe name & SSN the getter-funetions_ -should-eturma strm-andthe setter functions should take nly9ne parameter ach, a- Only the first & last name should be stored and returmed from the getter function Need helpo 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 o This class is only allowed to contain two string variables and four functions » staff: a staff class, which inherits from employee. Use public inheritance o Staff nd -separate-setterfunctionsfor 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. Need helpo o faculty: a faculty class, which inherits from employee. Use public inheritance * o -Staff -have a yearly-salary-whieh should have a setter function. get yearly_pay should simply return 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. Need help o oExplanation / Answer
#include <iostream>
#include <string>
#include <fstream>
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 //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 //1 double 3 func
{
public:
double get_yearly_pay();
void set_yearlysalary(double);
void set_name(string);
private:
double yearlysalary;
};
//EMPLOYEE CLASS FUNCTIONS START
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<strlen(ssn);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;
}
}
//EMPLOYEE CLASS FUNCTIONS END
//STAFF CLASS FUNCTIONS START
double staff::get_yearly_pay()
{
if(hoursperweek<=40){
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;
}
//STAFF CLASS FUNCTIONS END
//FACULTY CLASS FUNCTIONS START
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 END
int main(int __attribute__((unused)) argc, char **argv)
{
ifstream infile(argv[2]);
return 0;
}