import java.awt. * ; import java.awt.event. * ; public class weight ... { public static void main(String args[])...{ new Shu(); }} class Shu extends Frame ... { Label out1=new Label("你的身高"); TextField in1=new TextField(8); Label out5=new Label("cm"); Label out2=new Label("你的体重"); TextField in2=new TextField(8); Label out6=new Label("kg"); Label out3=new Label("你的性别"); CheckboxGroup cg=new CheckboxGroup(); Checkbox c1=new Checkbox("男性",cg,true); Checkbox c2=new Checkbox("女性",cg,true); Button b1=new Button("计算"); Button b2=new Button("清空"); Label out4=new Label("测试结果"); TextField in3=new TextField(25); Panel p1=new Panel(); Panel p2=new Panel(); Panel p3=new Panel(); public Shu()...{ setLayout(new GridLayout(3,1)); p1.setLayout(new FlowLayout()); p2.setLayout(new FlowLayout()); p3.setLayout(new FlowLayout()); p1.add(out1); p1.add(in1); p1.add(out5); p1.add(out2); p1.add(in2); p1.add(out6); p2.add(out3); p2.add(c1); p2.add(c2); p2.add(b1); p2.add(b2); p3.add(out4); p3.add(in3); add(p1); add(p2); add(p3); b1.addActionListener(new b11()); b2.addActionListener(new b22()); setSize(400,300); show(); addWindowListener(new WindowAdapter()...{ public void windowClosing(WindowEvent e)...{ System.exit(0); } }); }class b11 implements ActionListener...{public void actionPerformed(ActionEvent e)...{ int x=Integer.valueOf(in1.getText()).intValue();int y=Integer.valueOf(in2.getText()).intValue(); if(c2.getState())//女 ...{ if(y>(((x-100)*0.9-2.5)*0.9)&&y<(((x-100)*0.9-2.5)*1.1)) in3.setText("您的体重很标准,注意保持哦!!"); else if(y<(((x-100)*0.9-2.5)*0.9)) in3.setText("您的体重偏轻,要增加营养啊!!"); else if((((x-100)*0.9-2.5)*1.1)<y&&y<(((x-100)*0.9-2.5)*1.2)) in3.setText("您的体重超重啦,要注意啦!!"); else if((((x-100)*0.9-2.5)*1.2)<y&&y<(((x-100)*0.9-2.5)*1.3)) in3.setText("您有点轻度肥胖,该减肥了!!"); else if((((x-100)*0.9-2.5)*1.3)<y&&y<(((x-100)*0.9-2.5)*1.5)) in3.setText("您中度肥胖,一定要减肥了!!"); else in3.setText("不敢相信世界上还有......!!"); } if(c1.getState())//男 ...{ if(y>((x-100)*0.9*0.9)&&y<((x-100)*0.9*1.1)) in3.setText("您的体重很标准,注意保持哦!!"); else if(y<((x-100)*0.9*0.9)) in3.setText("您的体重偏轻,要增加营养啊!!"); else if(((x-100)*0.9*1.1)<y&&y<((x-100)*0.9*1.2)) in3.setText("您的体重超重啦,要注意啦!!"); else if(((x-100)*0.9*1.2)<y&&y<((x-100)*0.9*1.3)) in3.setText("您有点轻度肥胖,该减肥了!!"); else if(((x-100)*0.9*1.3)<y&&y<((x-100)*0.9*1.5)) in3.setText("您中度肥胖,一定要减肥了!!"); else in3.setText("不敢相信世界上还有......!!"); } } } class b22 implements ActionListener...{ public void actionPerformed(ActionEvent e)...{ in1.setText(""); in2.setText(""); in3.setText(""); } }}