package pack_sgyc;
import java.applet.Applet;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.List;
import java.awt.Button;
import java.awt.TextField;
import java.awt.Checkbox;
import java.awt.Font;
import java.text.DecimalFormat;
public class Aplt_sgyc extends Applet {
private static final long serialVersionUID = 1L;
private Label label1 = null;
private Label label2 = null;
private Label label3 = null;
private Label label4 = null;
private Label label5 = null;
private List list1 = null;
private Button button1 = null;
private Button button2 = null;
private TextField textField1 = null;
private TextField textField2 = null;
private Checkbox checkbox1 = null;
private Checkbox checkbox2 = null;
/**
* This is the default constructor
*/
public Aplt_sgyc() {
super();
}
/**
* This method initializes this
*
* @return void
*/
public void init() {
label5 = new Label();
label5.setBounds(new Rectangle(103, 288, 163, 32));
label5.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
label5.setText("");
label4 = new Label();
label4.setBounds(new Rectangle(66, 157, 109, 30));
label4.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
label4.setText("你的性别:");
label3 = new Label();
label3.setBounds(new Rectangle(9, 108, 166, 30));
label3.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
label3.setText("母亲身高(米):");
label2 = new Label();
label2.setBounds(new Rectangle(9, 59, 166, 30));
label2.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
label2.setText("父亲身高(米):");
label1 = new Label();
label1.setBounds(new Rectangle(89, 7, 185, 30));
label1.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
label1.setText("身高的科学预测系统");
this.setLayout(null);
this.setSize(368, 329);
this.add(label1, null);
this.add(label2, null);
this.add(label3, null);
this.add(label4, null);
this.add(label5, null);
this.add(getList1(), null);
this.add(getButton1(), null);
this.add(getButton2(), null);
this.add(getTextField1(), null);
this.add(getTextField2(), null);
this.add(getCheckbox1(), null);
this.add(getCheckbox2(), null);
}
/**
* This method initializes list1
*
* @return java.awt.List
*/
private List getList1() {
if (list1 == null) {
list1 = new List();
this.list1.add("男");
this.list1.add("女");
list1.setBounds(new Rectangle(100, 190, 80, 57));
list1.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
}
return list1;
}
/**
* This method initializes button1
*
* @return java.awt.Button
*/
private Button getButton1() {
if (button1 == null) {
button1 = new Button();
button1.setBounds(new Rectangle(95, 247, 90, 30));
button1.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
button1.setLabel("身高预测");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
double hf,hm,h;
String str;
str = textField1.getText();
hf = Double.parseDouble(str);
str = textField2.getText();
hm = Double.parseDouble(str);
if(list1.getSelectedIndex()==0){
h = (hf+hm)*0.52;
}
else
h=(hf*0.923+hm)*0.5;
if(checkbox1.getState()==true){
h*=1.02;
}
if(checkbox2.getState()==true){
h*=1.015;
}
//str = Double.toString(h);
DecimalFormat df = new DecimalFormat("0.00");
str = df.format(h);
label5.setText(str);
}
});
}
return button1;
}
/**
* This method initializes button2
*
* @return java.awt.Button
*/
private Button getButton2() {
if (button2 == null) {
button2 = new Button();
button2.setBounds(new Rectangle(214, 246, 90, 30));
button2.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
button2.setLabel("清屏复位");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
//System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
textField1.setText("");
textField2.setText("");
list1.select(-1);
checkbox1.setState(false);
checkbox2.setState(false);
label5.setText("");
}
});
}
return button2;
}
/**
* This method initializes textField1
*
* @return java.awt.TextField
*/
private TextField getTextField1() {
if (textField1 == null) {
textField1 = new TextField();
textField1.setBounds(new Rectangle(182, 61, 129, 30));
textField1.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
}
return textField1;
}
/**
* This method initializes textField2
*
* @return java.awt.TextField
*/
private TextField getTextField2() {
if (textField2 == null) {
textField2 = new TextField();
textField2.setBounds(new Rectangle(182, 106, 129, 30));
textField2.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
}
return textField2;
}
/**
* This method initializes checkbox1
*
* @return java.awt.Checkbox
*/
private Checkbox getCheckbox1() {
if (checkbox1 == null) {
checkbox1 = new Checkbox();
checkbox1.setBounds(new Rectangle(209, 154, 113, 32));
checkbox1.setLabel("喜欢 运动");
checkbox1.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
}
return checkbox1;
}
/**
* This method initializes checkbox2
*
* @return java.awt.Checkbox
*/
private Checkbox getCheckbox2() {
if (checkbox2 == null) {
checkbox2 = new Checkbox();
checkbox2.setBounds(new Rectangle(209, 191, 113, 32));
checkbox2.setLabel("营养良好");
checkbox2.setFont(new Font("\u4eff\u5b8b_GB2312", Font.BOLD | Font.ITALIC, 18));
}
return checkbox2;
}
} // @jve:decl-index=0:visual-constraint="23,0"
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
用于身高预测的小程序 规则:男孩升高:父母身高的和乘以0.52(称为先天性身高)如果后天喜欢运动,则身高增加2%,如果后天营养良好,则身高增加1.5%; 女孩身高:父亲身高乘以0.923后再与母亲身高求平均,如果后天喜欢体育运动,则身高增加2%,如果后天营养良好,则身高增加1.5%
资源推荐
资源详情
资源评论
收起资源包目录
proj_shen_gao_yc.rar (5个子文件)
aaa.html 143B
pack_sgyc
Aplt_sgyc.java 6KB
Aplt_sgyc$2.class 1KB
Aplt_sgyc.class 4KB
Aplt_sgyc$1.class 2KB
共 5 条
- 1
兰斯洛特Lancelot
- 粉丝: 46
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页