package introduction.outputformatting;

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Created by jsong on 03/03/2017.
 * <p>
 * hackerrank	: https://www.hackerrank.com/jsong00505
 * github		: https://github.com/jsong00505
 * linkedin		: https://www.linkedin.com/in/junesongskorea/
 * email		: jsong00505@gmail.com
 * <p>
 * challenge	: Java Output Formatting
 */
public class Solution {
	public static void main(String[] args) {
		try(
			Scanner in = new Scanner(System.in);
			PrintWriter out = new PrintWriter(System.out);
		) {
			out.println("================================");
			for(int i = 0; i < 3; i++){
				String s1 = in.next();
				int x = in.nextInt();
				//Complete this line

				// get s1's length
				int lenS1 = s1.length();

				// print s1 first
				out.print(s1);

				// fill white space to the rest of s1
				for(int j = 0; j < 15 - lenS1; j++ ) {
					out.print(" ");
				}

				// fill 0 to the rest of x then print
				String strX = x < 10? "00" + x : (x < 100? "0" + x : Integer.toString(x));
				out.println(strX);
			}
			out.println("================================");
		} catch (Exception e) {

		}

	}
}

@@ -725,16 +725,30 @@
 s length
+ for iterating
 %0A%09%09%09%09int
@@ -1068,16 +1068,104 @@
 n(strX);
+%0A%0A%09%09%09%09// TODO: this is the editorial solution%0A%09%09%09%09// out.printf( %22%25-15s%2503d %25n%22, s1, x);
 %0A%09%09%09%7D%0A%09%09

add editorial's solution