Check out example codes for "The purpose of this exercise is to test your understanding of formatting output using printf.". It will help you in understanding the concepts better.

Code Example 1

public static void main(String args[]){
    Scanner scanner =  new Scanner(System.in);

    for (int i=0;i<2;i++){
       String string = scanner.next();
       int num = scanner.nextInt();


       System.out.printf("%-14s %03d %n", string, num);       //note the use of printf
       // %-14s  fifteen characters left-justified o to 14
       // %03d padded with leading zero

    }
}

Learn ReactJs, React Native from akashmittal.com