Ive written all of the code out and it works fine for Am times.....but when i type in a time(in military time) that is after 12 noon, the output still reads AM and not PM. Heres the code that i wrote out if someone could help me see where i went wrong, i woild appreciate it.
--------------------------------------------------------------------------
#include<iostream>
using namespace std;
void calculate(int& h, double& m);
void display(int h, double m);
int main()
{
int hours;
double minutes;
cout<<"Enter the time in 24 hours military standard hours:"<<endl;
cin>>hours;
cout<<"Enter the time in 24 hours military standard minutes:"<<endl;
cin>>minutes;
calculate(hours, minutes);
display(hours, minutes);
return 0;
}
void calculate(int& h, double& m)
{
if(h<=12)
{
h=h-0;
m=m-0;
}
if(h>12 && h<=24)
{
h=h-12;
m=m-0;
}
}
void display(int h, double m)
{
if(h<=12)
{
cout<<"The time in 12 hour format is:"<<h<<":"<<m<<"AM."<<endl;
}
if(h>12 && h<=24)
{
cout<<"The time in 12 hour format is:"<<h<<":"<<m<<"PM."<<endl;
}
}