how many of each lower case vowel is in string
I know this is a question that has been asked quite a bit but has not been answered the way I need my code to be. It can use the while, for, and if loops. All I need for the rest of my code ist to count the vowels. I can the code to print which vowels are in the string but not how many of each vowel. Here is what I have.
import java.util.*;
public class Vowel
{
public static void main(String[] args)
{
String str;
char c;
int count = 0;
Scanner scan = new Scanner(System.in);
System.out.println ("Enter a word: ");
str = scan.nextLine();
for (int i = 0 ; i < str.length () ; i++)
{
c = str.charAt(i);
if (c == 'a'|| c == 'e' || c == 'i' || c == 'o' || c == 'u')
System.out.println (c);
}
}
}
[837 byte] By [
Vanzena] at [2007-11-27 11:21:02]

well show us what you've tried. that's a good place to start. But remember, if you want to make your code readable so that someone smart will read it and comment on it, please surround your code with code tags when posting. You can find out about them here:
http://forum.java.sun.com/help.jspa?sec=formatting
> yea i know but how do i go about it cause I tried but
> with out luck.
So you know how to increment a variable in your for loop statement but don't know how to do it anywhere else? :confused:
> I cant use the count method either,
> not allowed to.
Excuse my ignorance but what is the count method?
> > yea i know but how do i go about it cause I tried
> but
> > with out luck.
>
> So you know how to increment a variable in your for
> loop statement but don't know how to do it anywhere
> else? :confused:
Well, you see, I know how to count blocks ...
... but I do not know how to count oranges!
--Grover
jverda at 2007-7-29 14:46:12 >

Well, you see, I know how to count blocks ...
... but I do not know how to count oranges!
--Grover
Priceless!