I'm new here but think I'm going to become a regular visitor now that I started my Java class. I am having trouble with one of my assignments, I have a toString method that is supposed to print out information on a triangle. My problem is I am trying to format the numbers to 2 or 3 decimal places but having some difficulty. Here is my toString method
The call to the toString method looks like this
The length variables as well as the perimeter and area are the ones that are of type double and are the ones I'm trying to round off to 3dp.
Agree with Rob; my preference would be to use Rob's first suggestion. That is very closely related to the Formatter methods; I think it simply creates a Formatter object and passes the arguments on to that.