i need to separate the string and integer and also to display it in separate columns [closed]

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

    }
}

}

Leave a Comment