0

I need help figuring out how to do error checking with military time. So that if the value is over 59 (ex 1372) it gives an error message. My C++ knowlege is fairly basic

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by CoolGamer48
0

Um, do you mean something like:

if(minutes > 59)
{
//whatever error you want to come up, ex:
cout << "Error: minutes entered was over 59";
}

where minutes is already defined as the number of minutes you got from the user.

0

Would that mean i'd have to get the time from user twice. Once for hour and once for minutes? Right now it's just accepting the time as a whole (in military)

0

Would that mean i'd have to get the time from user twice. Once for hour and once for minutes? Right now it's just accepting the time as a whole (in military)

time as a whole in what format? as a string? separated by a colon?(e.g., 13:49) you don't need to ask the user for input twice (that might make things easier though) but you do need to somehow separate the hours and minutes values (either before our after you ask for the input)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.