I want round to round to the nearest 10th instead of the nearest integer... Any ideas?
public class Triangle { private final int leg; private final double hypotenuse; public Triangle( int l ) { leg = l; hypotenuse = leg*Math.sqrt( 2.0 ); } public int getLeg() { return leg; } public double getHypotenuse() { return hypotenuse; } @Override public String toString() { return String.format( "Triangle(%d)", leg ); } }
Triangle(5)
Leg: 5
Hypotenuse: 7.0 (this should be 7.1)