This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi everyone!!! I'm a super beginner taking some classes at a local community college. We're on writing methods right now, and I'm running into a roadblock. I have the code below written so far for the method I'd like to use (i can post the full file code if you'd like).
int vowels;
char ch;
for(int i = 0; i < input.length() ; i ){
vowels = 0;
//as i increases, so does the position being tested.
ch = input.charAt(i);
if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o'
|| ch == 'O' || ch == 'u' || ch == 'U' || ch == 'y' || ch == 'Y'){
vowels ; //increases vowels variable, such that it only will increase if the
//string has characters matching one of those characters
}
}
return vowels;
}
Currently, the "return vowels;" portion of the code (on line 16) is giving an error, and I'm stumped as to why.
EDIT: Full code is posted in comments in response to /u/Nincodedo
EDIT 2: It has been solved!! I needed to initialize vowels outside the loop instead of inside in this case. Thanks again to /u/Nincodedo.
Subreddit
Post Details
- Posted
- 7 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/javahelp/co...