+ 1

Help with Military Time Code Coach c++ [Solved]

Code attached. Task is described in attached file, below the code. Code passes all but test #4 (hidden). I have tried every possible combination to test this. Obviously the most important places to test are where the time transitions. Ex. 11:59 AM to 12:00 PM (12:00) 11:59 PM (23:59) to 12:00 AM (00:00) 9:00 PM (21:00) to 10:00 PM (22:00) etc. I know the code could likely be better and more efficient (I'm a newbie and want to first use methods covered in the course), but first I need to know *why* it's failing. Then I'll ask about other methods, once I feel I've solved the task myself. Regardless of method, if it's failing I need to figure out where the error is. The code outputs (for ex.) 00:10 (12:00 AM input) 01:10 thru 09:10 10:10 11:10 12:10 13:10 (1:00 PM input) thru 23:10 then back to 00:00 So I'm completely stumped here. Any suggestions regarding why it may be failing only test#4 greatly appreciated.

18th Nov 2022, 6:30 AM
Scott D
Scott D - avatar
5 odpowiedzi
+ 2
Scott D be careful not to make the fallacy of overgeneralization. One example input does not necessarily define all the requirements. You might have to revisit your assumptions if you can find no other cause of failure.
18th Nov 2022, 8:12 AM
Brian
Brian - avatar
+ 2
Brian You could be right, but then either the Sample Input of the question should not be phrased that way or mine probably should have failed more than one test. I do get your point, but it's frustrating to spend several hours on such a task to find out the task description is not specified correctly. It's not really an "assumption" when one is following directions. Maybe that's part of learning to code but it's still frustrating. I'll alter my code to take that into consideration but...
18th Nov 2022, 8:24 AM
Scott D
Scott D - avatar
+ 2
Brian Thanks once again, I really appreciate your help.
18th Nov 2022, 10:13 PM
Scott D
Scott D - avatar
+ 1
Brian Try entering 2:30 AM Look at the task description, below the code I posted Sample Input: 1:15 PM There is no 0 before the 1. Therefore there should be no 0 before 2:30 AM.
18th Nov 2022, 7:55 AM
Scott D
Scott D - avatar
0
Scott D I entered 02:30 AM and it wrongly printed 00:30.
18th Nov 2022, 7:50 AM
Brian
Brian - avatar