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 8947053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:39:20+00:00 2026-06-15T12:39:20+00:00

I have this problem for homework (I’m being honest, not trying to hide it

  • 0

I have this problem for homework (I’m being honest, not trying to hide it at least)
And I’m having problems figuring out how to do it.

Given the following declarations : String phrase = ” WazzUp ? – Who’s On FIRST ??? – IDUNNO”; Write the necessary code to
count the number of vowels in the string and print appropriate message to the screen.

Here’s the code I have so far:

String phrase =  " WazzUp ? - Who's On FIRST ??? - IDUNNO";
int i, length, vowels = 0;
String j;
length = phrase.length();
for (i = 0; i < length; i++)
{

  j = phrase.substring(i, i++);
  System.out.println(j);

  if (j.equalsIgnoreCase("a") == true)
    vowels++;
  else if (j.equalsIgnoreCase("e") == true)
    vowels++;
  else if (j.equalsIgnoreCase("i") == true)
    vowels++;
  else if (j.equalsIgnoreCase("o") == true)
    vowels++;
  else if (j.equalsIgnoreCase("u") == true)
    vowels++;

}
System.out.println("Number of vowels: " + vowels);

However, when I run it it just makes a bunch of blank lines. Can anyone help?

  • 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-06-15T12:39:21+00:00Added an answer on June 15, 2026 at 12:39 pm

    phrase.substring(i, i++); should be phrase.substring(i, i + 1);.

    i++ gives the value of i and then adds 1 to it. As you have it right now, String j is effectively phrase.substring(i, i);, which is always the empty string.

    You don’t need to change the value of i in the body of the for loop since it is already incremented in for (i = 0; i < length; i++).

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

Sidebar

Related Questions

I'm trying to figure out this problem for a CS homework assignment (I'll tag
I have this problem for homework that I am having a hard time finding
This is my homework, but please read my problem description first. I have to
I have this problem having to display my jasper report on my grails application.
I have this homework problem where I need to use regex to remove every
I am stumped on this homework problem. I think I have the right answer
-- EDIT -- Worth to point out. While having a problem with different homework
so i have this homework and this is the given problem: Per-minute charging offers
I am trying to solve a homework problem where I have to return a
This is not a homework problem. I am only going over a freely available

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.