hey can someone help look over my code? I am trying to turn normal time into military time for a bigger program.
[void Beux::get_times()
{
cout<<"What hour did you depart on your frist day out?";
cin>>depart_hr;
cout<<"What minute was the flight supposed to leave?";
cin>>depart_minute;
while ((depart_minute>=60)||(depart_minute<0)) {
cout<<"Need legitimate minutes, try again."<<endl;
cin>>depart_minute;
}
cout<<"What your flight in the am or pm? (type a for am and p for pm)"<<endl;
cin>>depart_end;
depart_end=tolower(depart_end);
if ((depart_end=='p')&&((depart_hr<12)&&(depart_hr<0)))
{
depart_hr=depart_hr+12;
}
else if ((depart_hr==12)&&(depart_end=='a'))
{
depart_hr=0;
}
cout<<depart_hr;
cout<<"What time did you arive home? Enter Hours, then Minutes, then a for am or p for pm.";
cin>>arival_hr;
cin>>arival_minute;
cin>>arival_end;
arival_end=tolower(arival_end);
if ((arival_end=='p')&&((arival_hr<12)||(arival_hr<24))) {
arival_hr=arival_hr+12;
}
else if ((arival_hr==12)&&(arival_end=='a'))
{
arival_hr=0;
}
cout<<arival_hr<<endl;
If depart_hr is less than 12 AND it's less than zero? If it's less than zero, won't it always be less than 12? So why bother checking for less than 12? Did you really mean this?