Write a C++ program which contains a class named Time having three datamembers .
ID: 3608044 • Letter: W
Question
Write a C++ program which contains a class named Time having three datamembers.
The class must have
· A default and parameterizedconstructor
· show() method to displaythe time in proper format like HH:MM:SS on the screen
· get() method to get timefrom user
· OverloadedPlus (+) andMinus (-)operators
· A destructor
You will overload + and - operator for this class.
In main program make 3 objects of the Time class time1, time2 and time3 and call theget()functions for time1 and time2 then perform time3 = tim1+time2 andthen you will display time3 using its show() function.
Note1: While Adding the time keep in mind do not just add thehours into hours and minutes into minutes and seconds in seconds ,e.g
10:25:10
+01:45:25
---------------------
11: 70: 35
Will not be correct, instead your code should add times like,Note that as number of minutes have increased 60, hour have beenincreased.
10:25:10
+ 01:45:25
-------------------
12: 10: 35
Note 2: You willsubmit source code file only.
Deadline
Your assignment mustbe uploaded/submitted on or before 23rd January,2008
Write a C++ program which contains a class named Time having three datamembers.
- Hours
- Minutes
- Seconds
The class must have
· A default and parameterizedconstructor
· show() method to displaythe time in proper format like HH:MM:SS on the screen
· get() method to get timefrom user
· OverloadedPlus (+) andMinus (-)operators
· A destructor
You will overload + and - operator for this class.
In main program make 3 objects of the Time class time1, time2 and time3 and call theget()functions for time1 and time2 then perform time3 = tim1+time2 andthen you will display time3 using its show() function.
Note1: While Adding the time keep in mind do not just add thehours into hours and minutes into minutes and seconds in seconds ,e.g
10:25:10
+01:45:25
---------------------
11: 70: 35
Will not be correct, instead your code should add times like,Note that as number of minutes have increased 60, hour have beenincreased.
10:25:10
+ 01:45:25
-------------------
12: 10: 35
Note 2: You willsubmit source code file only.
Deadline
Your assignment mustbe uploaded/submitted on or before 23rd January,2008
Explanation / Answer
x.x
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.