#include <iomanip>
#include <iostream>
using std::cout;
using std::endl;
using std::setfill;
using std::setw;
class Time
{
public:
Time();
void setTime( int, int, int );
void printUniversal();
void printStandard();
private:
int hour;
int minute;
int second;
};
Time::Time()
{
hour = minute = second = 0;
}
void Time::setTime( int h, int m, int s )
{
hour = h ;
minute = m;
second = s ;
}
void Time::printUniversal()
{
cout << setfill( '0' ) << setw( 2 ) << hour << ":" << setw( 2 ) << minute << ":" << setw( 2 ) << second;
}
void Time::printStandard()
{
cout << ( ( hour == 0 || hour == 12 ) ? 12 : hour "
<< setfill( '0' ) << setw( 2 ) << minute << ":" << setw( 2 )
<< second << ( hour < 12 ? " AM" : " PM" );
}
int main()
{
Time t;
t.printUniversal();
t.printStandard();
t.setTime( 1, 2, 6 );
t.printUniversal();
t.printStandard();
t.setTime( 99, 99, 99 );
t.printUniversal();
t.printStandard();
return 0;
}
00:00:0012:00:00 AM01:02:061:02:06 AM99:99:993:99:99 PM