网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

下面是一个Applet程序,其功能是计算山顶的高度,计算方法是:该山顶由a点量得仰角度数为a,由b点量得仰角度数为b,且测得a,b点之间的距离为c,求山的高度。要求窗口中有3个输入框,分别作为a、b、c的输入,一个按钮单击后进行计算,结果显示在另一个文本框中<这个文本框不可编辑)。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。

注意:不改动程序的结构,不得增行或删行。

源程序文件代码清单如下:

import java.io.*;

import java.awt.*;

import java.awt.event.*;

import java.applet.Applet;

/*

<applet code="ex6_3.class"width=800 height=400>

</applet>

*/

public class ex6_3 extends Applet implements ActionListener

{

Panel pane=new Panel();

Label 11=new Label("a点仰角:");

TextField tf1=new TextField(5);

Label 12:=new Label("b点仰角:");

TextField tf2=new TextField(5);

Label 13=new Label("a,b之间距离:");

TextField tf3=new TextField(5);

Button btn=new Button("OK");

Label 14=new Label("山高:");

TextField tf4=new TextField(20);

ex6_3 Obj23_3;

public void init()

{

pane.setLayout(new FlowLayout(PlowLayout.LEFT,10,5));

pane.add(11);

pane.add(tf1);

pane.add(12);

pane.add(tf2);

add("North",pane);

Panel p2=new Panel();

p2.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));

p2.add(13);

p2.add(tf3);

p2.add(btn);

btn.addActionListener(this);

add("Center",p2);

Panel p3=new Panel();

p3.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));

p3.add(14);

tf4.setEditable(true);

p3.add(tf4);

add("South",p3);

Obj23_3=new ex6 3();

}

public void doMessure(double a1,double a2,double a3,TextField tf)

{

double pi=Math.PI,a,b,h;

a=al*pi/180.0;

b=a2*pi/180.0;

h=a3/(1.0/Math.tan(a)-1.0/Math.tan(b));

tf.setText(Integer.toString(h));

}

public void actionPerformed(ActionEvent ae)

{

double a,b,c;

try

{

a=new Double(tf1.getText()).doubleValue();

b=new Double(tf2.getText()).doubleValue();

c=new Double(tf3.getText()).doubleValue();

obj23_3.doMessure(a,b,c, tf4};

}catch(NumberFormatExceptlon nfe)

{

tf4.setText("wrong number!");

}

}

}

ex6_3.html

<HTML>

<HEAD>

<TITLE>ex6_3</TITLE>

</HEAD>

<BODY>

<applet code="ex6_3.class"width=800 height=400>

</applet>

</BODY>

</HTML>


参考答案

更多 “ 下面是一个Applet程序,其功能是计算山顶的高度,计算方法是:该山顶由a点量得仰角度数为a,由b点量得仰角度数为b,且测得a,b点之间的距离为c,求山的高度。要求窗口中有3个输入框,分别作为a、b、c的输入,一个按钮单击后进行计算,结果显示在另一个文本框中<这个文本框不可编辑)。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。源程序文件代码清单如下:import java.io.*;import java.awt.*;import java.awt.event.*;import java.applet.Applet;/*<applet code="ex6_3.class"width=800 height=400></applet>*/public class ex6_3 extends Applet implements ActionListener{Panel pane=new Panel();Label 11=new Label("a点仰角:");TextField tf1=new TextField(5);Label 12:=new Label("b点仰角:");TextField tf2=new TextField(5);Label 13=new Label("a,b之间距离:");TextField tf3=new TextField(5);Button btn=new Button("OK");Label 14=new Label("山高:");TextField tf4=new TextField(20);ex6_3 Obj23_3;public void init(){pane.setLayout(new FlowLayout(PlowLayout.LEFT,10,5));pane.add(11);pane.add(tf1);pane.add(12);pane.add(tf2);add("North",pane);Panel p2=new Panel();p2.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));p2.add(13);p2.add(tf3);p2.add(btn);btn.addActionListener(this);add("Center",p2);Panel p3=new Panel();p3.setLayout(new FlowLayout(FlowLayout.LEFT,10,5));p3.add(14);tf4.setEditable(true);p3.add(tf4);add("South",p3);Obj23_3=new ex6 3();}public void doMessure(double a1,double a2,double a3,TextField tf){double pi=Math.PI,a,b,h;a=al*pi/180.0;b=a2*pi/180.0;h=a3/(1.0/Math.tan(a)-1.0/Math.tan(b));tf.setText(Integer.toString(h));}public void actionPerformed(ActionEvent ae){double a,b,c;try{a=new Double(tf1.getText()).doubleValue();b=new Double(tf2.getText()).doubleValue();c=new Double(tf3.getText()).doubleValue();obj23_3.doMessure(a,b,c, tf4};}catch(NumberFormatExceptlon nfe){tf4.setText("wrong number!");}}}ex6_3.html<HTML><HEAD><TITLE>ex6_3</TITLE></HEAD><BODY><applet code="ex6_3.class"width=800 height=400></applet></BODY></HTML> ” 相关考题
考题 下列不属于地貌特征点的是()。 A、山顶点B、鞍部点C、变坡点D、河岸线转弯点

考题 大气垂直温差的正常状态是A.由地表到上空,气温逐渐升高B.由地表到上空,气温逐渐降低C.由地表到上空,气温没有变化D.由地表到山顶,气温渐高,山顶以上气温渐低E.由地表到山顶,气温渐低,山顶以上气温渐高

考题 下面是一个Applet程序,其功能是计算山顶的高度,计算方法是:该山顶由a点量得仰角度数为a度,由b点量得仰角度数为b度,且测得a,b点之间的距离为c米,求山的高度。要求窗口中有3个输入框,分别作为a,b,c的输入,一个按钮点击后进行计算,结果显示在另一个文本框中(这个文本框不可编辑)。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。源程序文件代码清单如下:import java.io.*;import java.awt.*;import java.awt.event.*;import java.applet.Applet;/*<applet code="ex6_3.class" width=800 height=400 ></applet>*/public class ex6_3 extends Applet implements ActionListener{Panel pane=new Panel();Label 11 = new Label("a 点仰角:");TextField tfl = new TextField(5);Label 12 = new Label("b 点仰角:");TextField tf2 = new TextField(5);Label 13 = new Label("a,b 之间距离:");TextField tf3 = new TextField(5);Button btn = new Button("OK");Label 14=new Label ("山高");TextField tf4=new TextField(20);ex6_3 obj23_3;public void init(){pane.setLayout (new FiowLayout(FlowLayout.LEFT,10,5));pane.add (11);pane.add (tf1);pane.add (12);pane.add (tf2);add ("North", pane);Panel p2=new Panel();p2.setLayout(new FlowLayout (FlowLayout. LEFT, 10,5));p2.add(13);p2.add (tf3);p2.add(btn);btn. addActionListener (this);add ("Center", p2);Panel p3=new Panel();p3.setLayout(new FlowLayout (FlowLayout.LEFT,10,5));p3.add(14);tf4. setEditable (true);p3.add(tf4);add ("South", p3);obj23_3=new ex6_3();}public void doMessure(double al,double a2,double a3,TextField tf){double pi=Math. PI,a,b,h;a=al*pi/180.0;b=a2*pi/180.0;h=a3/(1.0/Math. tan (a) -1.0/Math. tan (b));tf.setText (Integer.toString(h));}public void actionPerformed(ActionEvent ae){double a,b, c;try{a=new Double(tf1.getText()) .doubleValueb=new Double(tf2,getText ()) .doubleValuec=new Double(tf3.getText()) .doubleValueobj23_3.doMessure(a,b,c, tf4);}catch (NumberFormatException nfe){tf4.setText("wrong number!");}}}ex6_3. html<HTML><HEAD><TITLE>ex6_3</TITLE></HEAD><BODY><applet code="ex6_3.class" width=800 height=400 ></applet></BODY></HTML>

考题 可作为中小比例尺航测像片平面控制点的是( )。A. 尖山顶 B. 圆山顶 C. 弧形地物 D. 鞍部

考题 3、屋顶等级由高到低的排列是_______。A.庑殿顶、歇山顶、悬山顶、硬山顶B.庑殿顶、悬山顶、歇山顶、硬山顶C.庑殿顶、悬山顶、硬山顶、歇山顶D.硬山顶、歇山顶、悬山顶、庑殿顶

考题 下面定义中哪一个不正确答案A.山顶:山的最高部位叫山顶B.山背:是指从山顶到山脚的凸起部分,很像动物的脊背C.鞍部:是指相连梁山顶间的凹部分D.山背、鞍部相连形成的凸棱部分

考题 2、一个矢量的旋度是一个新矢量,下列描述正确的是A.某点旋度的大小为该点的环量密度B.某点旋度的大小为该点最大的环量密度C.某点旋度的方向为该点获得最大环量密度的面元的法线方向D.某点旋度的方向为该点获得环量密度的面元的法线方向

考题 筑物的屋面在顶部交汇为一点,形成尖顶,这种建筑的屋顶叫()。A.歇山顶B.攒尖顶C.硬山顶D.悬山顶

考题 矢量场中某点的旋度是一个矢量,其大小等于该点的最大环量密度,其方向为取得最大环量的环面的法线方向。