[说明] 下面是一段java代码,运行结果如图11-8所示。 程序代码如下: (1)Java.awt.Graphics; (2)Java.applet.Applet; // ////////////////////////

admin2010-01-29  40

问题 [说明] 下面是一段java代码,运行结果如图11-8所示。
  
   程序代码如下:
   (1)Java.awt.Graphics;
   (2)Java.applet.Applet;
   //  ////////////////////////////////////////////
   //  Display y=sin(x)
   public class J_DrawSin  (2) Applet
   {
       public void paint(Graphics g)
       {
          double d, tx;
          int x, y, x0, y0;
          d=Math.PI/100;    // Set step(Set the unit in x direction)
          x0=y0=0;
   (3)(tx=0, x=20; tx<2*Math.PI; tx+=d,x++)
        {
           y=120-(int)(Math.sin(tx)*50+60);
           if(x>20)
              g.drawLine(x0, y0, x, y);
           x0=x;
           y0=y;
        }
        g.drawstring("y=sin(x)", 10, 70);
      }  //End of method: paint
   }  //End of class: J_HelloApplet
   <!-----------------------AppletExample.html------------------->
   <HTML>
     <HEAD>
       <TITLE>
            An applet Example ---- Hello Applet!
       </TITLE>
       </HEAD>
       <BODY>
           <(4)CODE="J_DrawSin.class" WIDTH=300 HEIGHT=120>
           </APPLET>
       </BODY>
   </HTML>

选项

答案(1)import (2)extends (3)for (4)APPLET。

解析
转载请注明原文地址:https://kaotiyun.com/show/SwCZ777K
0

相关试题推荐
最新回复(0)