Java Output Formatting

  • + 0 comments

    public class Solution { public void display(String x,int y){ System.out.print(x);

        for(int i = x.length(); i < 15; i++){
            System.out.print(" ");
        }
    
            if(y<10){
                System.out.println("00"+y);
            }else if(y<100){
                System.out.println("0"+y);
            }else if(y<1000){
                System.out.println(y);
            }
    
    }
    
    public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
    
            String s1=sc.next();
            int x=sc.nextInt();
            String s2=sc.next();
            int y=sc.nextInt();
            String s3=sc.next();
            int z=sc.nextInt();
    
            Solution l = new Solution(); 
    
            System.out.println("================================");
            l.display(s1,x);
            l.display(s2,y);
            l.display(s3,z);
    
                //complete this line
    
            System.out.println("================================");
    
    }
    

    }