import javax.swing.JOptionPane;

/**
 * A program that parses a user-supplied URL, printing Yes if the
 * user input is a legal URL and printing No otherwise.
 * @author  Derek Bridge  666  d.bridge@cs.ucc.ie
 */
public class URLParser
{
   public static void main(String[] args)
   {  while (true)
      {  String input =
            JOptionPane.showInputDialog("URL: ");
         if (input == null) // Cancel was clicked
         {  System.exit(0);
         }
         input = input.trim();
         System.out.println(input + " " + parse(input));
      }
   }

   public static String parse(String theInput)
   {  String remainder = theInput.toLowerCase();
      String protocol = "";
      String host = "";
      String path = "";
      int posnOfDiv1 = remainder.indexOf("://");
      if (posnOfDiv1 == -1)
      {  return "No";
      }
      protocol = remainder.substring(0, posnOfDiv1);
      remainder = remainder.substring(posnOfDiv1 + 3);
      int posnOfDiv2 = remainder.indexOf("/");
      if (posnOfDiv2 == -1)
      {  return "No";
      }
      host = remainder.substring(0, posnOfDiv2);
      path = remainder.substring(posnOfDiv2 + 1);
      if (protocolIsOK(protocol) &&
          isSeparatedLetters(host, '.') &&
          isSeparatedLetters(path, '/'))
      {  return "Yes";
      }
      else
      {  return "No";
      }
   }

   private static boolean protocolIsOK(String theProtocol)
   {  return theProtocol.equals("http");
   }

   private static boolean isSeparatedLetters(String theString, char theSep)
   {  if (theString.equals(""))
      {  return false;
      }
      if (theString.charAt(0) == theSep ||
          theString.charAt(theString.length() - 1) == theSep ||
          theString.indexOf("" + theSep + theSep)!= -1)
      {  return false;
      }
      for (int i = 0; i < theString.length(); i++)
      {  char c = theString.charAt(i);
         if (! Character.isLetter(c) &&
             c != theSep)
         {  return false;
         }
      }
      return true;          
   }
}

