We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

Uploading instructions

 

  • For clarity and simplicity, you are required to Upload/Submit only one .CPP file

Objective

The objective of this assignment is:

 

  • To give you the idea of practical implementation of class with attributes and functions

 

For any query about the assignment, contact at CS304@vu.edu.pk

 

GOOD LUCK

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

 

 

 

 

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 6235

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Attachments:

Replies to This Discussion

share your error..

source file not find

source file not compile

if u have win 7, use  devcpp-4.9.9.2_setup.exe .

in case of win 8, use http://sourceforge.net/projects/orwelldevcpp/ .

solution ,,,,

Attachments:

#include <iostream>
using namespace std;
class Time {
public:
Time(); // default constructor
void setTime(int,int,int);
void show24hour();
void show12hour();
private:
int hour;
int minute;
int second;
};
Time::Time()
{ hour = minute = second = 0; }


void Time::setTime(int h,int m,int s)
{
hour = (h >= 0 && h < 24) ? h : 0;
minute = (m >= 0 && m < 60) ? m : 0;
second = (s >= 0 && s < 60) ? s : 0;
}
// show time in 12 hour format
void Time::show12hour()
{
cout ((hour == 0 || hour == 12) ?12 : hour % 12) ;
cout ":" (minute < 10 ? "0" : "") minute ;
cout ":" (second < 10 ? "0" : "") second ;
cout (hour < 12 ? " AM" : " PM");
}
// show time in 24 hour format
void Time::show24hour()
{
cout (hour < 10 ? "0" : "") hour ":" ;
cout (minute < 10 ? "0" : "") minute ;
system("pause");
}


//main simple class Time
int main()
{

Time t; // instantiate object t of class Time
cout "initial time " endl;
cout "Time display in 12 hours format: ";
t.show12hour();
cout "\nTime display in 24 hours format: ";
t.show24hour();

t.setTime(13,55,23);
cout "\nAfter set: ";
cout "\nTime display in 12 hours format: ";
t.show12hour();
cout "\nTime display in 24 hours format: ";
t.show24hour();
t.setTime(25,67,98);

system("pause");
cout "\nAfter Setting invalid Values\n" ;

t.show12hour();
cout "\n" ;
t.show24hour();

cout endl;
return 0 ;
system("pause");

}

Sahrish MCS 2nd complete ni hy 

how???

kisi k pass full correct solution hai?

full discussion read kro bro

full correct solution mil jai ga

run kr k check kro 

RSS

Latest Activity

Farhan Amin replied to Farhan Amin's discussion your vu email address will deleted
1 hour ago
Farhan Amin replied to Farhan Amin's discussion your vu email address will deleted
1 hour ago
+ ! ! ! ! ! AaiMa AnsaRi liked + M.Tariq Malik's discussion CS201 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 14-11-2019
1 hour ago
+ ! ! ! ! ! AaiMa AnsaRi replied to + M.Tariq Malik's discussion MGT211 GDB Fall 2019 Solution & Discussion in the group MGT211 Introduction To Business
1 hour ago
+ ! ! ! ! ! AaiMa AnsaRi joined + M.Tariq Malik's group
1 hour ago
+ ! ! ! ! ! AaiMa AnsaRi liked + M.Tariq Malik's discussion MGT211 GDB Fall 2019 Solution & Discussion
1 hour ago
+ Abb@s replied to Farhan Amin's discussion your vu email address will deleted
1 hour ago
+ Danial replied to Farhan Amin's discussion your vu email address will deleted
2 hours ago
Shine--Ex-VUStudent liked + "J ɨ y ą ⋆'s discussion meliiiiiiii dailyyyyyyyyyyyyyyyyy milkkkkkkkkkkkkkkkkk :(
2 hours ago
+ Danial replied to Farhan Amin's discussion your vu email address will deleted
2 hours ago
Shine--Ex-VUStudent liked +"Certified Gangster"++'s discussion New invention of Microsoft
2 hours ago
Moji posted a discussion
2 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MGT211 GDB Fall 2019 Solution & Discussion in the group MGT211 Introduction To Business
2 hours ago
Muhammad Usman Shahzad replied to + M.Tariq Malik's discussion CS601 Assignment No 01 Fall 2019 Solution & Discussion Due Date: 14-11-2019 in the group CS601 Data Communication
2 hours ago
Muhammad Usman Shahzad joined + M.Tariq Malik's group
2 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to sayyad saqib hussain shah's discussion HRM 626 HANDOUTS REQUIRED PLS
3 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to Farhan Amin's discussion your vu email address will deleted
3 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MTH302 Business Mathematics & Statistics Assignment No 01 Fall 2019 Solution & Discussion in the group MTH302 Business Mathematics & Statistics
3 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MTH302 Business Mathematics & Statistics Assignment No 01 Fall 2019 Solution & Discussion in the group MTH302 Business Mathematics & Statistics
3 hours ago
+ "αяsαℓ " Ќąƶµяɨ •" replied to + M.Tariq Malik's discussion MTH302 Business Mathematics & Statistics Assignment No 01 Fall 2019 Solution & Discussion in the group MTH302 Business Mathematics & Statistics
3 hours ago

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service