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

  • SEARCH
  • Home
  • 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 653533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:23:35+00:00 2026-05-13T22:23:35+00:00

I have some basic idea on how to do this task, but I’m not

  • 0

I have some basic idea on how to do this task, but I’m not sure if I’m doing it right. So we have class WindyString with metod blow. After using it :

System.out.println(WindyString.blow(
    "Abrakadabra!          The    second  chance to pass has already BEGUN! "));

we should obtain something like this :

                    e              a  e         a           a  ea y
   br k d br !    Th    s c nd   ch nc    t    p ss   h s    lr  d    B G N!
  A  a a a  a            e o               o           a               E U

so in a nutshell in every second word we pick every vowels and move them one line above. In the second half of words we move vowels one line below.

I know I should split string to tokens with tokenizer or split method,but what next ? Create 3 arrays each representing each row ?

  • 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-13T22:23:35+00:00Added an answer on May 13, 2026 at 10:23 pm

    The simplest way is to use regex. This should be instructive:

    static String blow(String s) {
        String vowels = "aeiouAEIOU";
        String middle = s.replaceAll("[" + vowels + "]", " ");
        int flip = 0;
        String[] side = { "", "" };
        Scanner sc = new Scanner(s);
        for (String word; (word = sc.findInLine("\\s*\\S*")) != null; ) {
            side[flip] += word.replaceAll(".", " ");
            side[1-flip] += word.replaceAll("[^" + vowels + "]", " ");
            flip = 1-flip;
        }
        return String.format("|%s|%n|%s|%n|%s|", side[0], middle, side[1]);
    }
    

    I added the | characters in the output to show that this processes excess whitespaces correctly — all three lines are guaranteed the same length, taking care of leading blanks, trailing blanks, or even ALL blanks input.

    If you’re not familiar with regular expressions, this is definitely a good one to start learning with.

    The middle is simply the original string with all vowels replaced with spaces.

    Then, side[0] and side[1] are the top and bottom lines respectively. We use the Scanner to extract every word (preserving leading and trailing spaces). The way we process each word is that in one side, everything is replaced by blanks; in the other, only non-vowels are replaced by blanks. We flip sides with every word we process.

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

Sidebar

Ask A Question

Stats

  • Questions 424k
  • Answers 424k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Q_CORE_EXPORT is a macro that gets expanded to different values… May 15, 2026 at 11:49 am
  • Editorial Team
    Editorial Team added an answer On some platforms (and even versions), this is going to… May 15, 2026 at 11:49 am
  • Editorial Team
    Editorial Team added an answer Perhaps this will be helpful for you: http://asciicasts.com/episodes/211-validations-in-rails-3. The first… May 15, 2026 at 11:49 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.