Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6052531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:56:20+00:00 2026-05-23T07:56:20+00:00

class Test{ public static void main(String[] args) { String line = ALONE AMEND DATES

  • 0
class Test{   
    public static void main(String[] args) {     
        String line = "ALONE AMEND DATES DAWNS DEALS LEMON LENDS";
        int maxVowelAtChar = 4;     

        // need the help for this function.  
        String pure = myFunc(line, maxVowelChar);  
        System.out.println(pure);   
    }
} 

Now it should print :

DAWNS LENDS

After maxVowelAtChar there should not be any vowel. the count start from last character of word. “ALONE” does not qualify since it has vowel at char 1 & 3, similarly “LEMON” has vowel at char 2. “DAWNS” qualifies since it has no vowels upto 3rd characters(4th one is A). Help me please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:56:20+00:00Added an answer on May 23, 2026 at 7:56 am

    EDITED: This code passes the clarified requirements. Changed to count from end backwards.

    Before you criticise, see notes below.

    public static void main(String[] args)
    {
        String line = "ALONE AMEND DATES DAWNS DEALS LEMON LENDS";
        for (int maxVowelAtChar = 1; maxVowelAtChar < 6; maxVowelAtChar++)
        {
            String pure = myFunc(line, maxVowelAtChar);
            System.out.println(maxVowelAtChar + ": " + pure);
        }
    }
    
    private static String myFunc(String line, int maxVowelAtChar)
    {
        String pure = "";
    
        for (String word : line.split("\\s"))
        {
            // This regex is also sensitive to word length ie not being 5 like all test data
            if (word.matches("^.{" + (word.length() - maxVowelAtChar + 1) + "}[^aeiouAEIOU]*$"))
                pure += word + " ";
        }
    
        return pure.trim();
    }
    
    Output:
    1: ALONE AMEND DATES DAWNS DEALS LEMON LENDS
    2: AMEND DATES DAWNS DEALS LEMON LENDS
    3: AMEND DAWNS DEALS LENDS  
    4: DAWNS LENDS
    5: 
    

    This code has been simplified to illustrate the core of the solution. “Real” code would use a StringBuffer instead of String += String.

    What makes this work is the dynamic regex passed to matches that means “must end with n non-vowels”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Test { public static void main(String[] args) { } } class Outer
Here is the code: class Test { public static void main (String[] args) throws
I have this class: public class Test { public static void main(String[] args) {
public class test { public static void main(String[] args) { int MAX = 5;
Take a look at this code: public class Test { public static void main(String...
I have following code public class TEST { public static void main(String arg[]){ try
I have the following code: public class Test { public static void Main() {
using System; using System.Math; class test { public static void Main() { Console.Write(Enter any
Here is a little test program: #include <iostream> class Test { public: static void
Running the following (example) code import java.io.*; public class test { public static void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.