import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;

public class ReadAlice 
{
   public static void main(String[] args) throws MalformedURLException, IOException
   {
      URL url = new URL("http://www.laughton.com/obrien/sjsu/cs49j/lessons/lesson20_io/alice30.txt");
      Scanner scan = new Scanner(url.openStream());
      scan.useDelimiter("");
      
      int digits = 0;
      int letters = 0;
      int punctuation = 0;
      int totalCount = 0;
      while (scan.hasNext())
      {
         char ch = scan.next().charAt(0);
         totalCount++;
         
         if (Character.isLetter(ch))
         {
            letters++;
         }
         else if (Character.isDigit(ch))
         {
            digits++;
         }
         else if (!Character.isWhitespace(ch))
         {
             punctuation++;
         }
      }
      
      if (totalCount > 0)
      {
         System.out.println("% letters: " + (double)letters / totalCount * 100);
         System.out.println("% digits: " + 100.0 * digits / totalCount );
         System.out.println("% punctuation: " + (double)punctuation / totalCount * 100);
      }
      scan.close();
   }
}
