0
What is lacking with my military time code?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int ntime; String time = input.nextLine(); String [] arr=time.split(":"); if(arr[1].charAt(3)=='P'){ ntime=Integer.parseInt(arr[0])+12; } else ntime=Integer.parseInt(arr[0]); String ttime[]=arr[1].split(" "); System.out.print(ntime+":"+ttime[0]); } }
4 Respuestas
+ 2
Does your version take care of cases like 01:23?
+ 1
The output has to look for example like this: 01:23.
+ 1
I get it now thanks bro
0
You mean 1:23 PM or AM? or just 1:23?