Java Applet 实现双精度浮点数整数部分提取
import java.awt.; import java.applet.;
public class Prog1 extends Applet { Label label = new Label('请输入一个双精度浮点数:'); TextField in = new TextField(18); Label out = new Label('');
public void init() {
add(label);
add(in);
add(out);
}
public boolean action(Event e, Object o) {
if (e.target == in) {
double num = Double.valueOf(in.getText());
int integerPart = (int) num;
out.setText('其整数部分为:' + integerPart);
repaint();
}
return true;
}
}
原文地址: https://www.cveoy.top/t/topic/oD9x 著作权归作者所有。请勿转载和采集!