+ 1
[SOLVED]Test Cases not passed in Military Time(Code Coach) problem?
Can somebody please explain what are the test cases that my code is failing in the Military Time(Code Coach) question?My Code link is given below : https://code.sololearn.com/cp4ELY8R55w4/?ref=app
10 Réponses
+ 2
Bahha🐧 Thank You very much,now i understand what was the problem and what were those 2 test cases that were failing.The Sololearn community is indeed wonderful,always ready to help people out.Thanx again for investing your time in the question.Cheers 👍
+ 2
Thanks this I could finish that challenge (I had the same issues)
Here's my solution. I'm practicing English too xD.
https://code.sololearn.com/cSJD7rmif6OD/?ref=app
+ 1
12:00 AM is supposed to be 00:00
your code outputs 12:00
+ 1
Bahha🐧 No it is correct it is showing the output 00:00,i have checked that,the problem is somewhere else
+ 1
enter 12:00 AM as input for the code in the link above it will output 12:00
it should output 00:00
+ 1
Bahha🐧 i checked that again for 12:00 AM and it is showing 00:00,what are you talking about,please check again for this input?
+ 1
lol you're right, I entered 12:00 AM from autocomplete and it added a space automatically "12:00 AM " so I got the wrong output 12:00.
I will check your code again.
+ 1
Bahha🐧 No problem bro 👍 and thanks for checking out my problem.
+ 1
Bahha🐧 you can try copying and pasting my code in the Military Time question in the Code Coach and it is failing 2 hidden test cases.I am unable to figure out the problem in my solution ☹️
+ 1
Prakhar Srivastava
ok I checked your code, everything is fine. except that the output has to be in the format of xx:xx even for AM time.
for example input 1:00 AM should output 01:00 not 1:00
at the end of your code before print.
check the length of the substring 0 to : of ot, if it is 1 then in print ("0"+ot) else print (ot).
something like :
String len = ot.substring(0, ot.indexOf(":") ;
if(len.length() == 1){
System.out.print("0"+ot);
else {
System.out.print(ot) ;
}
or use another way to get two digits before :