我有多个需要输入的字段,经过一定的处理后输出结果。我的问题是,无论什么原因,math.round似乎总是向下舍入而不是四舍五入。
这里有一个例子:
private void method(){
int X= Integer.parseInt(XjTF.getText());
int Y= Integer.parseInt(YjTF.getText());
float Z =(X+Y)/6;
int output = Math.round(Z);
OutputjTF.setText(Integer.toString(output)+" =answer rounded to closest integer");
}