Question: Task: A. Write a program that defines and implements a class Time. The class Time should consist of three private member variables of type int:

 Task: A. Write a program that defines and implements a class

Task: A. Write a program that defines and implements a class Time. The class Time should consist of three private member variables of type int: hour, minute, and second. The class Time should also include the following public member functions: 1. print to print the hour minute, and second in the format of HH-MM-SS (Hint: consider using output manipulators setw and setfill). 2. setTime to accept three int arguments and use them to set the hour, minute and second member variables. A valid value for hour is between 0 and 23. A valid value for minute or second is between 0 and 59. For any invalid values, use 0 instead. 3. getHour to return the value of hour 4. getMinute to return the value of minute. 5. getSecond to return the value of second. 6. A default constructor to initialize hour, minute and second to 0. 7. An overloaded constructor that accepts three int arguments and use them to initialize hour, minute and second. Data validation should be considered Hints: Call the setTime function with 3 arguments B. In the main function, write statements to declare class objects and test your class implementation by calling its member functions. For example, Time getupTime getupTime.setTime (6, 30, 0 get upTime. print( ); cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!