Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cs304 first may spring semester for mcs 2015 final solution
#1
Solution for cs304 first may spring semester of virtual university of Pakistan 2015
  • 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:
[Image: attachment.php?attachmentid=24785&stc=1]


Attached Files
.jpg   CS304ObjectOrientedProgrammingAssignmentNo.1Solution.jpg (Size: 20 KB / Downloads: 399)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CS703 – Advanced Operating Systems Assignment No.3 solution January 2016 Vuhelper 0 5,905 01-23-2016, 09:58 PM
Last Post: Vuhelper
  CS601 Data Communication Assignment No. 03 Solution 23rd January 2016 Vuhelper 1 1,926 01-23-2016, 06:09 PM
Last Post: Vuhelper
  CS403 Assignment No. 03 Solution 23rd January 2016 Vuhelper 2 1,162 01-23-2016, 03:18 PM
Last Post: Vuhelper
  CS506 Web Design and Development Assignment no 3 Solution 3rd January 2016 Vuhelper 0 2,240 01-23-2016, 03:16 PM
Last Post: Vuhelper
  CS724 Software Process Improvement Assignment No 01 Solution 20th January 2016 Vuhelper 0 1,964 01-20-2016, 06:26 PM
Last Post: Vuhelper
  CS711 Software Design Assignment No 01 Solution Due Date Feb 12, 2016 Vuhelper 0 1,661 01-20-2016, 06:24 PM
Last Post: Vuhelper
  CS709 Formal Methods for Software Engineering Assignment No 01 Solution January 2016 Vuhelper 0 1,795 01-20-2016, 06:22 PM
Last Post: Vuhelper
  cs703 assignment no 3 Solution 20th January 2016 Vuhelper 0 1,698 01-20-2016, 06:20 PM
Last Post: Vuhelper
  CS704 Assignment No. 01 Solution January 2016 Vuhelper 0 4,795 01-20-2016, 06:19 PM
Last Post: Vuhelper
  Data Warehousing– CS614 Assignment No. 3 solution 20th Jauary 2016 Vuhelper 0 9,574 01-20-2016, 06:16 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)