Question
In C++. Design a class called NumDays. The class's purpose is to store a value that represents a number of work hours and convert it
In C++. 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 class should 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.
The program that you create will have a driver in main() which tests the entire functionality of your program.
MUST INCLUDE:
class called NumDays that stores the number of hours in a private member variable.
The class has a NumDays(int) constructor and it is tested in the main() function.
The class has a member function for storing hours and it is tested in the main() function.
The class has a member function for retrieving hours and it is tested in the main() function.
The class has a member function for retrieving days and it is tested in the main() function.
The class has a member function for retrieving days and it is tested in the main() function.
The class has an overloaded subtraction operator and it is tested in the main() function.
The class has an overloaded postfix increment operator and it is tested in the main() function.
The class has an overloaded prefix increment operator and it is tested in the main() function.
The class has an overloaded postfix decrement operator and it is tested in the main() function.
The class has an overloaded prefix decrement operator and it is tested in the main() function.
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