Design a class called numdays


Design a class called NumDays. The class's purpose is to store a value that represents a number of work hours and convert it to a number of days. For example, 8 hours would be converted to 1 day, 12 hours would be converted to 1.5 days, and 18 hours would be converted to 2.25 days. The class should have a constructor that accepts a number of hours, as well as member functions for storing and retrieving the hours and days.

The classshould also have the following overloaded operators:
• The addition operator +. The number of hours in the sum of two objects is the sum
of the number of hours in the individual objects.
• The subtraction operator -. The number of hours in the difference of two objects X
and Y is the number of hours in X minus the number of hours in Y.
• Prefix and postfix increment operators ++. The number of hours in an object is
incremented by 1.
• Prefix and postfix decrement operators --. The number of hours in an object is
decremented by 1.

=========================================================================

I had a program written, but failed to create a class and follow all the specifications. Please make sure to do so. Must be able to run Microsoft Studio Express 2013

=========================================================================

Will tip handsomely for speedy delivery & easy to read code

=========================================================================

Some of what I have:
HEADER (MISSING SOME PARTS TO GET IT RUNNING):

using namespace std;
#include
#include
class NumDays
{
private:
int hours;
public:
NumDays() {hours = 0;}
NumDays(int);
NumDays(double);
void setHours(int);
void setDays(double);
int getHours();
double getDays();
operator double();
NumDays operator+(const NumDays&);
NumDays operator-(const NumDays&);
NumDays operator++(int);
NumDays operator--(int);
NumDays operator++();
NumDays operator--();
};

//******************************************************************
NumDays::NumDays(int hparam)
{
hours = hparam;
}

//******************************************************************
NumDays::NumDays(double dparam)
{
hours = dparam * 8.0;
}

//******************************************************************
void NumDays::setHours(int h)
{
h = getHours();
}

//******************************************************************
void NumDays::setDays(double d)
{
d = getDays();
}

//******************************************************************
int NumDays::getHours()
{
return(hours);
}

//******************************************************************
double NumDays::getDays()
{
return(hours / 8.0);
}

//**************************************************************
NumDays NumDays::operator++(int)
{
NumDays temp(hours);
hours++;
return temp;
}

//******************************************************************
NumDays NumDays::operator--(int)
{
NumDays temp(hours);
hours--;
return temp;
}

//******************************************************************
NumDays NumDays::operator++()
{
++hours;
return *this;
}

//******************************************************************
NumDays NumDays::operator--()
{
--hours;
return *this;
}

============================================================================

MAIN:

int main()
{
NumDays Employee1(20),
Employee2(15);
cout << "Employee1++: " << Employee1++.getHours() << endl;
cout << "Employee1: " << Employee1.getHours() << endl;
cout << "++Employee1: " << (++Employee1).getHours() << endl;
cout << "Employee1: " << Employee1.getHours() << endl;
cout << "Employee2--: " << Employee2--.getHours() << endl;
cout << "Employee2: " << Employee2.getHours() << endl;
cout << "(--Employee2)--: " << (--Employee2)--.getHours() << endl;
cout << "Employee2: " << Employee2.getHours() << endl; //PROBLEM HERE
cout << " days: " << Employee2.getDays() << endl; //AND HERE

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Design a class called numdays
Reference No:- TGS086618

Expected delivery within 24 Hours