0
I have a number in Double coming from an object (think) and will be displayed in a table abstractTable. I would like it to be displayed with only two houses after the point. My code below:
public Double preco = 1.0;
public Double precoDesconto = 1.0;
int desconto = rs.getInt("desconto");
System.out.println("Após verificar na DAO, o desconto é: " + desconto);
if (desconto == 1) {
precoDesconto = preco * 0.3847;
} else if (desconto == 2) {
precoDesconto = preco * 0.405;
}
try {
return dados.get(linha).getPreco() * getDesconto(getDesconto(precoDesconto));
} catch (FileNotFoundException ex) {
System.out.println("\n" + this + " Erro ao obter preco com desconto: " + ex);
}
Note: I am calculating the discount percentage of a priced product preco
and each user will have a different discount desconto
. The discounted price is expressed in precoDesconto
.
It should help you https://answall.com/questions/30701/formation-de-um-double-java
– G. Bittencourt