-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS.cpp
More file actions
49 lines (40 loc) · 1.04 KB
/
Copy pathOOPS.cpp
File metadata and controls
49 lines (40 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*C++ program to read time in HH:MM:SS format and convert into total seconds.*/
#include <iostream>
#include <iomanip>
using namespace std;
class Time
{
private:
int seconds;
int hh=1,mm=1,ss=6;
public:
void get_Time(void);
void convert_Into_Seconds(void);
void display_Time(void);
};
void Time::get_Time(void)
{
cout << "Entered time is:" << endl;
cout << "Hours? "<<hh<<endl;
cout << "Minutes? "<<mm<<endl;
cout << "Seconds? "<<ss<<endl;
}
void Time::convert_Into_Seconds(void)
{
seconds = hh*3600 + mm*60 + ss;
}
void Time::display_Time(void)
{
cout << "The time is = " << setw(2) << setfill('0') << hh << ":"
<< setw(2) << setfill('0') << mm << ":"
<< setw(2) << setfill('0') << ss << endl;
cout << "Time in total seconds: " << seconds;
}
int main()
{
Time T; //creating objects
T.get_Time();
T.convert_Into_Seconds();
T.display_Time();
return 0;
}