#include<iostream>
using namespace std;
void inp(int&,int&);
void conv(int&,int&,char&);
void outp(int,int,char);
void main()
{
int hours,minutes;
char ampm;
char loopdesire;
do{
void inp(hours,minutes);
void conv(hours,minutes,ampm);
void outp(hours,minutes,ampm);
cout<<"Do you wish to conduct a another conversion (y/n)?";
cin>>loopdesire;
}while(loopdesire=='y' || loopdesire=='Y');
}
void inp(int& hours,int& minutes)
{
do{
cout<<"Please enter hour";
cin>>hours;
if(hours > 23)
cout<<"Enter hour value between 0 and 23";
}while (hours>23);
do{
cout<<"Please enter minute";
cin>>minutes;
if(minutes>59)
cout<<"Enter minute value between 0 and 59";
}while (minutes>59);
}
void conv(int& hours, int& minutes, char& ampm)
{
if(hours>12)
{
hours=hours-12;
ampm='P';
}
else if(hours==12)
{
ampm='P';
}
else
{
ampm='A';
}
}
void outp(int hours, int minutes, char ampm)
{
cout<<"The time is"<<hours<<":"<<minutes<<ampm<<"M"<<" in A.M P.M. notation";
} |