As the title says, I want to limit the number of decimals that result from an operation with variables of type double, this result is displayed in a JTextArea of a JFrame.
The code that does the operation and prints the result in the JTextArea is as follows: ( la
, lb
and lc
represent the sides of a triangle, a
calculates the area and A
is the JTextArea where the result is printed).
if (lb+lc>la && la+lc>lb && la+lb>lc){
a=Math.sqrt((la+lb+lc)*(-la+lb+lc)*(la-lb+lc)*(la+lb-lc)/16);
p=la+lb+lc;
A.setText("El triangulo es "+t+".\nEl area es ("+a+").\nEl perimetro es ("+p+").");