I am a beginner in Java, I have written a simple input java program. I am giving the user the option to repeat the program with a do while, however it's not properly functioning. Can someone point my mistake please?
public static void main(String args[]){
    char repeat = 0;
    Scanner input = new Scanner(System.in);
    do{ 
        String word = null;
        boolean oneWord = false;
        while(!oneWord){
            System.out.println("Please enter a word: ");
            try{
                word = input.nextLine().toLowerCase();
                word= word.trim();
                int words = word.isEmpty() ? 0 : word.split("\\s+").length;
                if(words==1 && word.length()>1 && word.length()<100){
                    System.out.println("Success");
                    oneWord = true;
                    System.out.println("Continue(Y/N)");
                    repeat = input.next().charAt(0);
                }else{
                    System.out.println("Failure.");
                }
            } catch (Exception e) {
                System.out.println("Exception occurred");
            }
        }
    }while(repeat=='Y'|| repeat=='y');
    input.close();
}
 
     
     
    