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

Recommended Answers

All 3 Replies

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.

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)

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.