Hey,
I'm still fairly new to C++, and even more new to this forum. Any help would be greatly appreciated. Could someone look at this segment of code for me and tell me what is wrong with the "if" statements to change the time. I'm not getting the output that I want; though, it is pretty close.
void ChangeTimeToMil(int hours, int minutes, string AMPM, int& time)
{
if((AMPM == "AM" || AMPM == "am")&& hours == 12)
{
time = minutes;
cout << " " << setfill('0') << setw(4) << time;
}
else if((AMPM == "AM" || AMPM == "am") && (hours >= 0 && hours <= 9))
{
time = (hours*100) + minutes;
cout << " " << setfill('0') << setw(4) << time;
}
else if((AMPM == "AM" || AMPM == "am") && (hours >= 10 || hours <= 11))
{
time = (hours*100) + minutes;
}
else if(AMPM == "PM" || AMPM == "pm" && (hours > 12))
{
time = (hours + 12)*100 + minutes;
cout << " " << setfill('0') << setw(4) << time;
}
else if((AMPM == "PM" || AMPM == "pm") && (hours == 12))
{
time = 1200 + minutes;
cout << " " << setfill('0') << setw(4) << time;
}
}
I'm sure it's something quite simple, but I can't find it.
Thanks again,
Gadgetman_53