问答题
System.out.println("sum="+sum);
【参考答案】
length;
j<b[i].length;
sum+=b[i][j];
点击查看答案
<上一题
目录
下一题>
热门
试题
问答题
请完成下列Java程序。程序的执行结果是生成一个具有一个TextField类型的对象in、But ton类型的对象btn和Label类型的对象out图形用户界面,程序的功能是计算用户输入数的平方。 注意:请勿改动main()主方法和其他已有的语句内容,仅在下画线处填人适当的语句。 import java.awt.*; import java.awt.event.*; public class PingFangShu public static void main(String args[]) __________ class AppFrame extends Frame TheAdapterTest listener=new TheAdapterTest(); TextField in=new TextField(5); Button btn=new Button( 计算 ); Label out=new Label( 显示计算结果 ); public AppFrame() setLayout(new FlowLayout()); add(in); add(btn); add(out); btn.addActionListener(new BtnActionAdapter()); addWindowListener(listener); setSize(400,100); show(); class BtnActionAdapter implements ActionListener public void actionPerformed(ActionEvent e) String s=in.getText(); double d=__________ double sq=d*d; out.setText(d+ 的平方是: +sq); class TheAdapterTest extends WindowAdapter public void windowClosing(WindowEvent e) System.exit(1);
点击查看答案
问答题
下面Applet程序的功能是统计在平面坐标系第一象限中,半径大于9,小于10的圆环中坐标值为整数的点有多少并且给出其坐标值。请改正程序中的错误(有下画线的语句),使程序执行后,能得到预期的结果。 import java.awt.*; import java.applet.*; * <applet code=Di9Ti width=200 height=100> < applet> * public class Di9Ti extends Applet public void paint(Graphics g) int x,y,r1=5,r2=4; int count=0; for(x=1;x<y;x++) for(y=1;y<r1;y) if(x*x+y*y<=r2*r2||x*x+y*y>=r1*r1) break; g.drawStdng( x= +x+ y= +y,20+count*80,20); count++; g.drawString( count= +count,20,40); ex11_3.html: <html> <head> <title>A Simple Program< title> < head> <body> <applet code= Di9Ti.class width=800 height=400> < applet> </body> </html>
点击查看答案
相关试题
下面Applet程序的功能是统计在平面坐标系第...
请完成下列Java程序。程序的执行结果是生成...