Program # 6 DUE: Specified on Canvas Program Purpose Mandatory Instructions This
ID: 3703397 • Letter: P
Question
Program # 6 DUE: Specified on Canvas Program Purpose Mandatory Instructions This progmn wil calize twe dasses, NanDays and TimeOit The se diasos will then be uwod in ckont sounce file Part I: NumDays Class Croate a clss called Nn Daya which wil would be sutootcallycovarted to I day, 12 hours wodd be convertod to 13 days, nd 18 hours would be Type be clas declwstion wikh dats members and member function prototypes into a file named numwlaysh os defaisom ia Private data members dos (double) 2 Publie member functions: Overloaded coostructor-ccepts hours as parametor, aueatically caloua I/ Mutators void sethours(int); vold setDays (int); I Accessors int getHours () const double ge toays) const implemented as a member function number of hours steod in an oeject The days shoudld be asly // Operator overloa NunDays operator-(gonst Nu Days operatorHO: NunDays oper tClsplaysa MamDays objact in bhe 6m Deys:(hie days private dats br)folowed by h is dat member).5oe example below. This overload mus be implementad as anon-member fanctioa 20 >>operator that accepts vailues for aNam Deys object esterod asa double va lue of days (e.g.525jand sores the das in the NumDays objest's des members (ssume 8 hours is one day) Input of 2 25 days would be storod as 18 hous hours d as non-enber functions frlend astrean operatorcc( ostrean Sout, const Numcays &): art II-TimeOff Class eae s claus called ,Place the clse declaradon widh das menbers and mem ber fus tion protstypes ino a eaber funaton definitions in afile named dimeeLcppExplanation / Answer
////NumDays.h
#ifndef NUM_DAYS_H
#define NUM_DAYS_H
#include <iostream>
#include <string>
using namespace std;
//NumDays Class
class NumDays
{
private:
double hours;
double days;
public:
NumDays();
NumDays(double h);
void setHours(double h);
double getHours() const;
void setDays(double d);
double getDays() const;
};
#endif NUM_DAYS_H
------------------------------------------------------------
//NumDays.cpp
#include<iostream>
#include "NumDays.h"
using namespace std;
NumDays::NumDays()
{
hours=0;
days=0;
}
NumDays::NumDays(double h)
{
hours=h;
}
void NumDays::setHours(double h)
{
hours=h;
}
double NumDays::getHours() const
{
return hours;
}
void NumDays::setDays(double d)
{
days=d;
}
double NumDays::getDays() const
{
return days;
}
------------------------------------------------------------
//TimeOff.h
//Time Taken Class
#ifndef TIME_OFF_H
#define TIME_OFF_H
#include "NumDays.h"
#include <iostream>
#include <string>
class TimeOff : public NumDays
{
private:
string id;
string name;
NumDays maxVacation,vacTaken;
NumDays maxSick, sickTaken;
public:
//Constructor
TimeOff();
TimeOff(string, string);
// Accessors
string getName() const;
//Mutators
void setMaxVacDays(int h);
void setVacDays(int h);
void setMaxSickDays(int h);
void setSickDays(int h);
double getMaxSickDays() const;
double getSickDays() const;
double getMaxVacDays() const;
double getVacDays() const;
NumDays getVacBalance() const;
NumDays getSickBalance() const;
friend ostream &operator<<(ostream &out,const TimeOff &timeoff);
};
#endif TIME_OFF_H
------------------------------------------------------------
//TimeTaken.cpp
#include<iostream>
#include<string>
#include<iomanip>
#include "TimeOff.h"
using namespace std;
TimeOff::TimeOff ( )
{
this->id="";
this->name="";
}
//Embedded Constructors
TimeOff::TimeOff ( string id, string name)
{
this->id=id;
this->name=name;
}
//Mutators
void TimeOff::setMaxVacDays(int h)
{
maxVacation.setHours(h);
maxVacation.setDays(h/8);
}
void TimeOff::setMaxSickDays(int h)
{
maxSick.setHours(h);
maxSick.setDays(h/8);
}
void TimeOff::setVacDays(int h)
{
vacTaken.setDays(h/8);
vacTaken.setHours(h);
}
void TimeOff::setSickDays(int h)
{
sickTaken.setHours(h);
sickTaken.setDays(h/8);
}
double TimeOff::getSickDays() const
{
return sickTaken.getDays();
}
double TimeOff::getMaxSickDays() const
{
return maxVacation.getDays();
}
double TimeOff::getVacDays() const
{
return sickTaken.getDays();
}
double TimeOff::getMaxVacDays() const
{
return maxVacation.getDays();
}
NumDays TimeOff::getVacBalance() const
{
NumDays remain;
remain.setDays((maxVacation.getDays()-vacTaken.getDays()));
remain.setHours((maxVacation.getDays()-vacTaken.getDays())*8);
return remain;
}
NumDays TimeOff::getSickBalance() const
{
NumDays remainSick;
remainSick.setDays((maxSick.getDays()-sickTaken.getDays()));
remainSick.setHours((maxSick.getDays()-sickTaken.getDays())*8);
return remainSick;
}
ostream &operator<<(ostream &out,const TimeOff &timeoff)
{
NumDays rem=timeoff.getVacBalance();
out<<"=========Employee Time Off========="<<endl;
out<<"Employee ID:"<<timeoff.id<<endl;
out<<"Employee Name:"<<timeoff.name<<endl;
out<<"-------------------------------------------------------------"<<endl;
out<<left<<setw(40)<<"Vacation Days/Hours Earned:"
<<timeoff.maxVacation.getDays()<<"/"<<timeoff.maxVacation.getHours()
<<setw(40)<<" Vacation Days/Hours Taken:"
<<timeoff.vacTaken.getDays()<<"/"<<timeoff.vacTaken.getHours()
<<setw(40)<<" Vacation Balance Remainning:"
<<rem.getDays()<<"/"<<rem.getHours()
<<endl;
out<<"-------------------------------------------------------------"<<endl;
NumDays remSick=timeoff.getSickBalance();
out<<"=========Employee Time Off========="<<endl;
out<<"Employee ID:"<<timeoff.id<<endl;
out<<"Employee Name:"<<timeoff.name<<endl;
out<<"-------------------------------------------------------------"<<endl;
out<<left<<setw(40)<<"Sick Days/Hours Earned:"
<<timeoff.maxSick.getDays()<<"/"<<timeoff.maxSick.getHours()
<<setw(40)<<" Sick Days/Hours Taken:"
<<timeoff.sickTaken.getDays()<<"/"<<timeoff.sickTaken.getHours()
<<setw(40)<<" Sick Balance Remainning:"
<<remSick.getDays()<<"/"<<remSick.getHours()
<<endl;
out<<"==============================================================="<<endl;
return out;
}
------------------------------------------------------------
#include<iostream>
#include<string>
#include "NumDays.h"
#include "TimeOff.h"
using namespace std;
int main()
{
int numMonths;
TimeOff frodo("12345" ,"Frodo Baggins");
int months=4;
frodo.setMaxVacDays(months*12);
frodo.setMaxSickDays(months*8);
frodo.setVacDays(16);
frodo.setSickDays(12);
cout<<frodo<<endl;
for(int i=0;i<3;i++)
{
frodo.setMaxVacDays(12);
frodo.setMaxSickDays(8);
}
frodo.setVacDays(24);
cout<<frodo<<endl;
string id,name;
cout<<"Enter id: ";
cin>>id;
cout<<"Enter name: ";
cin>>name;
TimeOff someEmployee(id,name);
cout<<"Enter number of months [1-6] : ";
cin>>numMonths;
someEmployee.setMaxVacDays(numMonths*12);
someEmployee.setMaxSickDays(numMonths*8);
cout<<someEmployee<<endl;
system("pause");
return 0;
}
------------------------------------------------------------
Sample Output:
=========Employee Time Off=========
Employee ID:12345
Employee Name:Frodo Baggins
-------------------------------------------------------------
Vacation Days/Hours Earned: 6/48
Vacation Days/Hours Taken: 2/16
Vacation Balance Remainning: 4/32
-------------------------------------------------------------
=========Employee Time Off=========
Employee ID:12345
Employee Name:Frodo Baggins
-------------------------------------------------------------
Sick Days/Hours Earned: 4/32
Sick Days/Hours Taken: 1/12
Sick Balance Remainning: 3/24
===============================================================
=========Employee Time Off=========
Employee ID:12345
Employee Name:Frodo Baggins
-------------------------------------------------------------
Vacation Days/Hours Earned: 1/12
Vacation Days/Hours Taken: 3/24
Vacation Balance Remainning: -2/-16
-------------------------------------------------------------
=========Employee Time Off=========
Employee ID:12345
Employee Name:Frodo Baggins
-------------------------------------------------------------
Sick Days/Hours Earned: 1/8
Sick Days/Hours Taken: 1/12
Sick Balance Remainning: 0/0
===============================================================
Enter id: 1001
Enter name: john
Enter number of months [1-6] : 6
=========Employee Time Off=========
Employee ID:1001
Employee Name:john
-------------------------------------------------------------
Vacation Days/Hours Earned: 9/72
Vacation Days/Hours Taken: 0/0
Vacation Balance Remainning: 9/72
-------------------------------------------------------------
=========Employee Time Off=========
Employee ID:1001
Employee Name:john
-------------------------------------------------------------
Sick Days/Hours Earned: 6/48
Sick Days/Hours Taken: 0/0
Sick Balance Remainning: 6/48
===============================================================
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.