#include <iostream>
using namespace std;
class Time{
private:
int hours, minutes, seconds;
public:
void readData(){
cout<<"\nEnter hours: ";
cin>>hours;
cout<<"\nEnter minutes: ";
cin>>minutes;
cout<<"\nEnter seconds: ";
cin>>seconds;
}
void display(){
if (hours>12){
cout<<"\nTime in 12 hour format:\n";
hours=hours-12;
cout<<"\n"<<hours<<":"<<minutes<<":"<<seconds;
}
cout<<"\nTime in 12 hour format:\n";
cout<<"\n"<<hours<<":"<<minutes<<":"<<seconds;
}
};
int main()
{
Time t;
t.readData();
t.display();
return 0;
}
Comments
Leave a comment