I have the following code, which returns values of type float
. How can I make the result appear with two or more decimal places?
private void btnDividirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
float n1 = Float.parseFloat(txtNumerador.getText());
float n2 = Float.parseFloat(txtDenominador.getText());
float divisao = n1 / n2;
float resto = n1 % n2;
rsDivisao.setText(Float.toString(divisao));
rsResto.setText(Float.toString(resto));