import java.text.NumberFormat; public class MainClass { public static void main(String[] args) { NumberFormat nf = NumberFormat.getInstance(); for (double x = Math.PI; x < 100000; x *= 10) { String formattedNumber = nf.format(x); System.out.println(formattedNumber + "\t" + x); } } }
3.142 3.141592653589793 31.416 31.41592653589793 314.159 314.1592653589793 3,141.593 3141.5926535897934 31,415.927 31415.926535897932