Military time error checking

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 6
Reputation: legendofme is an unknown quantity at this point 
Solved Threads: 0
legendofme legendofme is offline Offline
Newbie Poster

Military time error checking

 
0
  #1
Apr 22nd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: Military time error checking

 
0
  #2
Apr 22nd, 2008
Um, do you mean something like:
  1. if(minutes > 59)
  2. {
  3. //whatever error you want to come up, ex:
  4. cout << "Error: minutes entered was over 59";
  5. }

where minutes is already defined as the number of minutes you got from the user.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 6
Reputation: legendofme is an unknown quantity at this point 
Solved Threads: 0
legendofme legendofme is offline Offline
Newbie Poster

Re: Military time error checking

 
0
  #3
Apr 22nd, 2008
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)
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 401
Reputation: CoolGamer48 is on a distinguished road 
Solved Threads: 40
CoolGamer48's Avatar
CoolGamer48 CoolGamer48 is offline Offline
Posting Pro in Training

Re: Military time error checking

 
0
  #4
Apr 22nd, 2008
Originally Posted by legendofme View Post
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)
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 436 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC