Source Code : Use Formatter to vertically align numeric values.
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Use Formatter to vertically align numeric values.
import java.util.Formatter;
public class Main {
public static void main(String[] argv) throws Exception {
double data[] = { 12.3, 45.6, -7.89, -1.0, 1.01 };
Formatter fmt = new Formatter();
fmt.format("%12s %12s
", "Value", "Cube Root");
for (double v : data) {
fmt.format("%12.4f %12.4f
", v, Math.cbrt(v));
}
System.out.println(fmt);
}
}
/* Value Cube Root
12.3000 2.3084
45.6000 3.5726
-7.8900 -1.9908
-1.0000 -1.0000
1.0100 1.0033
*/
Thank with us