1
I have the code below, which returns values of type float
. How can I get the result presented to 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));
But it’s supposed to present with two decimal places even if they’re zeroes ?
– Isac