1个回答
展开全部
圆的直径是矩形的宽吗,我做做。
public class Main
{ public static void main(String args[])
{
JX jx=new JX("求矩形去圆后面积");
}
}
import java.awt.*;
import java.awt.event.*;
import java.lang.String;
class JX extends Frame implements ActionListener
{
Label label;
TextField textLenth,textHeight;
TextArea 提示;
Button 确定;
JX(String s)
{
super(s);
setLayout(new FlowLayout());
textLenth=new TextField(8);
textHeight=new TextField(8);
label=new Label("请分别输入矩形的长与宽");
提示=new TextArea("这个程序的功能是将输入的长与宽的矩形"+'\n'+"面积减去宽对应直径的圆的面积;长比宽大");
确定=new Button("确定");
确定.addActionListener(this);
add(label);
add(textLenth);
add(textHeight);
add(确定);
add(提示);
setBounds(100,100,450,200);
setVisible(true);
validate();
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent windowevent){System.exit(0);}});
}
public void actionPerformed(ActionEvent e)
{
double m,n,s,s1,s2;
final double p = 3.14;
m=Double.parseDouble(textLenth.getText());
n=Double.parseDouble(textHeight.getText());
s1=m*n;
s2=n*n*p/4;
s=(s1-s2);
String result=Double.toString(s);
提示.setText(result);
}
}
public class Main
{ public static void main(String args[])
{
JX jx=new JX("求矩形去圆后面积");
}
}
import java.awt.*;
import java.awt.event.*;
import java.lang.String;
class JX extends Frame implements ActionListener
{
Label label;
TextField textLenth,textHeight;
TextArea 提示;
Button 确定;
JX(String s)
{
super(s);
setLayout(new FlowLayout());
textLenth=new TextField(8);
textHeight=new TextField(8);
label=new Label("请分别输入矩形的长与宽");
提示=new TextArea("这个程序的功能是将输入的长与宽的矩形"+'\n'+"面积减去宽对应直径的圆的面积;长比宽大");
确定=new Button("确定");
确定.addActionListener(this);
add(label);
add(textLenth);
add(textHeight);
add(确定);
add(提示);
setBounds(100,100,450,200);
setVisible(true);
validate();
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent windowevent){System.exit(0);}});
}
public void actionPerformed(ActionEvent e)
{
double m,n,s,s1,s2;
final double p = 3.14;
m=Double.parseDouble(textLenth.getText());
n=Double.parseDouble(textHeight.getText());
s1=m*n;
s2=n*n*p/4;
s=(s1-s2);
String result=Double.toString(s);
提示.setText(result);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询