Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called time that has three separate private int member data for hours, minutes, and seconds. One default constructor should initialize the int

image text in transcribedimage text in transcribed

Create a class called time that has three separate private int member data for hours, minutes, and seconds. One default constructor should initialize the int data to for hours, and 0 for minutes and seconds; another parameterized constructor should initialize it to fixed values of 10, 10, and 10 for hours, minutes, and seconds (arguments 10,10,10 provided in hard-coded fashion during object declaration in main)) respectively. A public member function should receive the time data from the user in 24 hours format; whereas a public member function should display the time in 24 hours (11:59:59) format. A private member function check time0, should validate that if the user provides the value of the time (hrmin:sec) using the mutator (setter) function of the class for an object, then the values are greater than 0 and less than or equal to 24 for hours; greater than or equal to 0 and less than or equal to 60 for minutes and seconds. If an incorrect value is entered as input by the user, they should be prompted about the error A non-member function addTime0 should add multiple objects of type time passed as arguments to this non-member function. Consider declaring addTime0 as a friend of the class time. In order to perform the addition of the time objects inside of the body of addTime0, overload the binary addition operator + by declaring and defining it as a public member function of class time. The main0 program should create an initialized time object which will invoke the parameterized constructor (hard code the values 10,10,10 during this object declaration) and a second object which will be invoking the default constructor. A third object should be created whose values will be initialized by the user by invoking the mutator (setter) function in the class time. Thereafter, the initial times of the all the three objects should be displayed back to the user by using the accessor (getter) function of the class. Finally, addTime0 should be invoked and the values of all the three objects should be added together storing the result in a fourth time object. Thereafter the result stored in the fourth object should be displayed to the user by again using the accessor (getter) function. Additionally, your program must have a custom header file to declare the class, functions, and other primitive header files that you might need for your program. Sample Output: These values should not be used in final submission; please use values from Section Input Cases) Enter Time in 24 hours format (Hours: Minutes: Seconds)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago