Assignment No. 04 FALL 2008 CS 201: Introduction toProgramming Total Marks: 20 D
ID: 3608111 • Letter: A
Question
Assignment No. 04
FALL 2008
CS 201: Introduction toProgramming
Total Marks: 20
Due Date: 23/01/09
Instructions
Please read the following instructions carefully beforesubmitting assignment:
It should be clear that your assignment will not get anycredit if:
o The assignment is submitted after due date.
o The submitted assignment does not open or filecorrupt.
o The assignment is copied.
Objective
The objective of this assignment is to provide hands onexperience of using
o Classes and Objects
o Operator overloading
Question
Marks:20
Write a C++ program which contains a class namedTime having three datamembers.
The class must have
· Adefault and parameterizedconstructor
· show() method to display the time in proper formatlike HH:MM:SS on the screen
· get() method to get time from user
· OverloadedPlus (+) and Minus (-)operators
· Adestructor
You will overload + and - operator for this class.
In main program make 3 objects of the Timeclass time1, time2 andtime3 and call the get()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 will submit source code fileonly.
Deadline
Your assignment must be uploaded/submitted on or before23rd January, 2008
Assignment No. 04
FALL 2008
CS 201: Introduction toProgramming
Total Marks: 20
Due Date: 23/01/09
Instructions
Please read the following instructions carefully beforesubmitting assignment:
It should be clear that your assignment will not get anycredit if:
o The assignment is submitted after due date.
o The submitted assignment does not open or filecorrupt.
o The assignment is copied.
Objective
The objective of this assignment is to provide hands onexperience of using
o Classes and Objects
o Operator overloading
Question
Marks:20
Write a C++ program which contains a class namedTime having three datamembers.
- Hours
- Minutes
- Seconds
The class must have
· Adefault and parameterizedconstructor
· show() method to display the time in proper formatlike HH:MM:SS on the screen
· get() method to get time from user
· OverloadedPlus (+) and Minus (-)operators
· Adestructor
You will overload + and - operator for this class.
In main program make 3 objects of the Timeclass time1, time2 andtime3 and call the get()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 will submit source code fileonly.
Deadline
Your assignment must be uploaded/submitted on or before23rd 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.