Java Output Formatting

  • + 1 comment

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
          System.out.println("=".repeat(32));
    
        for(int i = 0; i <3; i+=1)
        {
        String str = sc.nextLine();
        String program = str.substring(0, str.indexOf(" "));
        String version = str.substring(str.indexOf(" "), str.length()).trim();
        version = (version.length() < 3)? "0".repeat(3-version.length())+version: version;
        System.out.println(program + " ".repeat(15-program.length())+ version);
        }
         System.out.print("=".repeat(32));
        sc.close();
    }
    

    }