Solution for cs304 first may spring semester of virtual university of Pakistan 2015View more random threads:
- cs402 idea solution assignment no 2 fall 2010
- CS601 data communication assignment no 1 spring 2011 idea...
- CS504 Software Engineering-1 assignment no 5 fall January...
- CS410 Visual Programming Assignment No.3 Solution Spring...
- CS615 assignment no 4 fall 3 January 2012 virtual...
- CS609 System Programming assignment no 5 idea solution...
- Assignment No. 02 SEMESTER FALL 2011 CS607- Artificial...
- CS607 Assignment No. 03 Solution 20th January 2016
- MTH301 Calculus II Assignment No.3 Solution Fall Semester...
- ECO404 Managerial Economics Assignment No.1 Fall Semester...
Sponsored Links
- To give you the idea of practical implementation of class with attributes and functions
Problem Statement:
Consider the following attributes and functions of the class Time:
Attributes:
- int hour
- int minute
- int seconds
Functions:
- void setTime(int, int, int);
- void show12Hour();
- void show24Hour();
Write a program to instantiate the object of a class Time from the main() function and constructor is called of the class Time automatically to initialize the private data members of the class with 0. Time is printed on the screen in 12 hours format and 24 hours format as follows:
Initial Time:
Time display in 12 hours format: 12:00:00 AM
Time display in 24 hours format: 00:00
After that use the setTime() function to set the time by passing the 3 attributes of time i.e setTime(13,55,23) and show the time again after setting:
After set:
Time display in 12 hours format: 01:55:23 PM
Time display in 24 hours format: 13:55
Now try to use setTime() function for setting invalid values i.e setTime(25,67,98) . Your program should not set invalid values of time and show finally the time as initial.
Time display in 12 hours format: 12:00:00 AM
Time display in 24 hours format: 00:00
Sample Output:
Urgent call: 03455242488. | Virtual University Assignments
Virtual University GDBs | Virtual University Papers | Vu Projects | Vu Handouts
About Expert
There are currently 1 users browsing this thread. (0 members and 1 guests)