String ouput = String.format("%.2f + %.2f = %.2f",x,y,total);
System.out.println(output);
will give you the output with 2 decimal places or you can use DecimalFormat
as well.
0
solved How can I format this String with double x,y,total to two decimal places. output = (x + ” + ” + y + ” = ” + total);