Question
Hello, I am new to programming and need help with a solution for the source code to be written in C++ for the problem that
Hello, I am new to programming and need help with a solution for the source code to be written in C++ for the problem that will be underlined below. Please help me to understand, through good comments, what the code does. And, please list which part of the code is the .cpp and which is the .h . If you could also include a comment or place somewhere in the reply how to contact you if I have further questions, that would be so much appreciated! Thank you for your hard work, and helping me to achieve proper understanding.
Please see the following and complete as detailed:
Design a class called NumDays. The classs purpose is to store a value that will convert the number of worked hours 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 converted to 2.25 days. The class must have a constructor that accepts a number of hours. There must also be member function to set and get the hours and days. The class should have 2 data members, hours and days.
The class will have several operators:
the addition operator. This operator will add the hours of the two objects and return a new instance of the NumDays with its hours data member set to the sum of the other two objects.
the subtraction operator will also be overloaded which will subtract the two objects and return a new instance of the NumDays class.
the prefix and postfix increment operator. These operators should increment the number of hours stored in the object. It will return an instance of the NumDays object.
the prefix and postfix decrement operator. These operators should decrement the number of hours stored in the object. It will return an instance of the NumDays object.
Note that when the number of hours changes, the number of days should always be updated. The user of this class should be able to use the object in a statement like C = A + B; where A, B and C are instances of the NumDays class. Main must show that the class and all the operators work correctly.
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