Results 1 to 9 of 9
Thread: The java Strings
- 04-12-2009, 04:26 PM #1
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
- 04-12-2009, 05:16 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
First of all, please choose the correct sub-forum when you posting gain. This is not the correct place. I'll move your question to the correct place this time.
What you have to do is, take each character of the string and check it for a vowel or not.
- 04-13-2009, 05:11 AM #3
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
but how the code write?
- 04-13-2009, 01:21 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
You should do it. This is a forum, not a code bank. No one wants to do your homework. First show your effort, and if you have any question please ask it more clearly. We all can help you.
- 04-15-2009, 12:11 PM #5
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
i didn't understand what you reply in the second post. so i just asking like that. i have let you know my way is using s.indexOf() but i still can't get it. erm, is ok..
- 04-15-2009, 04:35 PM #6
What Eranga is telling you is that you have to show us why it it's working for you. What have you tried? Let's see your code.
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 04-16-2009, 03:11 AM #7
Member
- Join Date
- Apr 2009
- Posts
- 4
- Rep Power
- 0
oh. erm.. icic sorry Eranga. this is my code.
hope you all can help me
import java.io.*;
class countvowel
{
static DataInputStream s=new DataInputStream(System.in);
public static void main(String args [])throws IOException
{
String anyvowel;
System.out.println("Enter a string: ");
anyvowel=s.readLine();
System.out.println("String: "+anyvowel);
System.out.println();
int c = 0 ;
for (int b = 0 ; b < anyvowel.length() ; b++) {
if (anyvowel.charAt(b) == 'a' || anyvowel.charAt(b) == 'e'||anyvowel.charAt(b)=='i'||anyvowel.charAt(b)== 'o'||anyvowel.charAt(b)=='u') {
c++;
System.out.println("The vowel that have in the string:"+ anyvowel.charAt(b));
}
}
System.out.println("The total number of vowel in the String: "+c);
}
}
- 04-16-2009, 06:01 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Try this in the if logic.
Java Code:if(......) { c++; System.out.println("Vowel " + anyvowel.charAt(b) + " found at " + b); }
- 04-16-2009, 06:08 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Few things to pay your attention.
1. Please use the code tags when you posting again. Un-formatted cods are hard to read.
2. Naming conversions, in Java follows camel case. http://java.sun.com/docs/codeconv/ht...ions.doc8.html
Similar Threads
-
Subtracting Strings
By ravian in forum New To JavaReplies: 7Last Post: 10-08-2009, 07:26 PM -
Sorting strings in java?
By alexander.s in forum New To JavaReplies: 10Last Post: 09-01-2008, 05:14 AM -
Comparison of Strings
By Cero.Uno in forum New To JavaReplies: 3Last Post: 02-11-2008, 03:46 AM -
Comparing Strings
By Java Tip in forum Java TipReplies: 0Last Post: 12-03-2007, 10:44 AM -
reversing Strings
By Java Tip in forum Java TipReplies: 0Last Post: 11-11-2007, 09:24 PM
Bookmarks