
/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

public class Main
{
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        
        String sample = "the quick brown fox jumps over the laxy dog";
        String sample1="ther";
        int lengthLine = 10;
        
        stringExercise  se = new stringExercise(sample, lengthLine);
        
            }
}


class stringExercise
{
    private String sample;
    private int lengthLine;
    double stringsRequired;
    
    public stringExercise(String sample, int lengthLine)
    {
        this.sample=sample;
        this.lengthLine=lengthLine;
        
        checkString();
        
    }
    
    public String checkString()
    {
        int array;
        
        //no way to break the text;
        if ((sample.length()>=lengthLine) &&  (sample.indexOf(" ")==-1))
            {
                return null;
                
            }
        
        //this narrows down search and it would find     
        if (sample.length()<lengthLine)
        {
            return sample;
            
        }
        
        if ((sample.length()>=lengthLine) &&  (sample.indexOf(" ")!=-1))
            {
                System.out.println("should reach here");
                stringsRequired=Math.ceil(sample.length()/lengthLine);
                System.out.println("number strings required: " + stringsRequired);
                System.out.println("length of strings: " + lengthLine);
                
                
                int stringsRequiredConverted = (int) stringsRequired;
                
                String output[] =  new String[stringsRequiredConverted-1];
                
                array=0;
                for (int i=0; i<lengthLine;i=i+9)
                {
                    
                    System.out.println("value of i: " + i);
                    
                    
                    for (int k=0; k<=9;k++)
                    {
                        output[array]=output[array] + sample.charAt(k);
                    
                    }
                    
                    array++;
                }
                
                
            }
        
        return null;
        
    }
    
}