pastebin

Paste Search Dynamic
Recent pastes
Schedule
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. //import java.util.regex.*;
  5. import java.util.regex.Matcher;
  6. import java.util.regex.Pattern;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. public class Main
  10. {
  11.         public static void main (string[] args) throws java.lang.exception
  12.         {
  13.                 Scanner myObj = new Scanner(system.in);  // Create a Scanner object
  14.  
  15.                 system.out.println("Schedule according to compass:");
  16.  
  17.  
  18.                 while(myObj.hasNext()) // see if there's more
  19.                 {
  20.                         string schedule = myObj.nextLine();  
  21.  
  22.                         string schedParts[] = schedule.split("t");
  23.                         string workDate=schedParts[0];
  24.  
  25.                         if(schedParts.length>1)
  26.                         {
  27.                                 string workTime=schedParts[1];
  28.                                 string workLength=schedParts[2];
  29.  
  30.                                 string matchMe="(pm)|( )";
  31.                                 Pattern pattern = Pattern.compile(matchMe);
  32.                                 Matcher matcher = pattern.matcher(workTime);
  33.                                 workTime = matcher.replaceAll("");
  34.                                 boolean matchFound = matcher.find();
  35.                                 system.out.println(workDate+", "+workTime+", ");
  36.                         }
  37.  
  38.                         else if(!schedule.equals(workDate))
  39.                         {
  40.                                 system.out.println(workDate+", ");
  41.                         }
  42.  
  43.                         else if(schedule==workDate)
  44.                         {                               system.out.println();                   }
  45.                 }
  46.         }
  47. }
Parsed in 0.081 seconds