结构推理 当用户按T或t时,人为抛出一个算术异常,处理方式为打印出错信息。
【正确答案】要求:程序书写规范,无明显语法错误,有注释。
   参考程序如下:
   import java.awt.*;
   import java.applet.*;
   public class keyException extends Applet
   {
     final int LOWERCASE T = 116;
     final int UPPERCASE T = 84;
     String str;  int count=0;
     public void paint(Graphics g)
    {
     g.drawString(" "+str+count,  5,20) ;
    }
        public boolean keyDown(Event evt,  int key)
       {
         if    ((key   ==   LOWERCASE_T)     ||     (key   ==   UPPERCASE   T))
                 {
         try
       {
          throw new ArithmeticException();
       }
        catch(ArithmeticException e)
           {
       count++;
      str=e.toString();
       repaint();
     }
               return true;
    }
   return false;
    }
【答案解析】