fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. //import java.util.regex.*;
  7. import java.util.regex.Matcher;
  8. import java.util.regex.Pattern;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. Scanner myObj = new Scanner(System.in); // Create a Scanner object
  16.  
  17. //stackoverflow/questions/2296685/how-to-read-input-with-multiple-lines-in-java
  18. //stackoverflow/questions/56887493/how-to-take-multi-line-input-in-java search:HashmatWarrior
  19. while(myObj.hasNext()) // see if there's more
  20. {
  21. String schedule = myObj.nextLine(); // Read user input (from w3schools/java/java_user_input.asp)
  22.  
  23. //stackoverflow/questions/10004066/java-splitting-an-input-file-by-colons
  24. String schedParts[] = schedule.split("\t");
  25. String workDay=schedParts[0];
  26.  
  27. if(schedParts.length>1)
  28. {
  29. String workDate=schedParts[1];
  30. System.out.print(workDay+" "+workDate+", ");
  31.  
  32. if(schedParts.length>2)
  33. {
  34. String workTime=schedParts[2];
  35. String workLength=schedParts[3];
  36.  
  37. //w3 schools
  38. String matchMe="(pm)|( O)|( )";
  39. Pattern pattern = Pattern.compile(matchMe);
  40. Matcher matcher = pattern.matcher(workTime);
  41. workTime = matcher.replaceAll("");
  42. boolean matchFound = matcher.find();
  43. System.out.print(workTime+", ");
  44. }
  45. System.out.println();
  46. }
  47.  
  48. else if(schedParts.length==1)
  49. {
  50. System.out.println();
  51. }
  52. }
  53. }
  54. }
Success #stdin #stdout 0.2s 61068KB
stdin
Punches: Sun Dec 8, 2024
Type	Store	Status	Time	Hrs
SS	03660	Normal	4:30 PM	3:53
SB	03660	Normal	8:23 PM	0:16
EB	03660	Normal	8:39 PM	0:50
ES	03660	Normal	9:29 PM	
Punches: Tue Dec 10, 2024
Type	Store	Status	Time	Hrs
SS	03660	Normal	10:06 PM	7:49
Punches: Wed Dec 11, 2024
Type	Store	Status	Time	Hrs
SB	03660	Added	5:55 AM	0:10
EB	03660	Normal	6:05 AM	0:09
ES	03660	Normal	6:14 AM	
SS	03660	Normal	10:16 PM	2:33
Punches: Thu Dec 12, 2024
Type	Store	Status	Time	Hrs
SB	03660	Normal	12:49 AM	0:10
EB	03660	Normal	12:59 AM	4:34
SM	03660	Normal	5:33 AM	
EM	03660	Normal	6:03 AM	0:07
ES	03660	Normal	6:10 AM	
SS	03660	Normal	9:11 PM	6:07
Punches: Fri Dec 13, 2024
Type	Store	Status	Time	Hrs
ES	03660	Normal	3:18 AM	
Punches: Sat Dec 14, 2024
Type	Store	Status	Time	Hrs
SS	03660	Normal	7:12 PM	3:09
SB	03660	Normal	10:21 PM	0:12
EB	03660	Normal	10:33 PM	0:44
ES	03660	Normal	11:17 PM	
stdout
Type Store, Status, 
SS 03660, Normal, 
SB 03660, Normal, 
EB 03660, Normal, 
ES 03660, Normal, 

Type Store, Status, 
SS 03660, Normal, 

Type Store, Status, 
SB 03660, Added, 
EB 03660, Normal, 
ES 03660, Normal, 
SS 03660, Normal, 

Type Store, Status, 
SB 03660, Normal, 
EB 03660, Normal, 
SM 03660, Normal, 
EM 03660, Normal, 
ES 03660, Normal, 
SS 03660, Normal, 

Type Store, Status, 
ES 03660, Normal, 

Type Store, Status, 
SS 03660, Normal, 
SB 03660, Normal, 
EB 03660, Normal, 
ES 03660, Normal,