Source Code : Java formatted IO: Demonstrate printf().

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

Java formatted IO: Demonstrate printf().


public class MainClass {
  public static void main(String args[]) {
    System.out.println("Here are some numeric values " + "in different formats.
");

    System.out.printf("Various integer formats: ");
    System.out.printf("%d %(d %+d %05d
", 3, -3, 3, 3);

    System.out.println();

    System.out.printf("Default floating-point format: %f
", 1234567.123);
    System.out.printf("Floating-point with commas: %,f
", 1234567.123);
    System.out.printf("Negative floating-point default: %,f
", -1234567.123);
    System.out.printf("Negative floating-point option: %,(f
", -1234567.123);

    System.out.println();

    System.out.printf("Line-up positive and negative values:
");
    System.out.printf("% ,.2f
% ,.2f
", 1234567.123, -1234567.123);

  }
}


/*
Here are some numeric values in different formats.

Various integer formats: 3 (3) +3 00003

Default floating-point format: 1234567.123000
Floating-point with commas: 1,234,567.123000
Negative floating-point default: -1,234,567.123000
Negative floating-point option: (1,234,567.123000)

Line-up positive and negative values:
 1,234,567.12
-1,234,567.12

*/           
       

Thank with us