Tuesday, 15 February 2011

Java - Converting the characters in a string array depending on whether or not it's a vowel -



Java - Converting the characters in a string array depending on whether or not it's a vowel -

the method takes in name , tests whether character vowel or consonant. if it's vowel, makes character uppercase, if it's consonant, makes character lowercase. thoughts? don't know how add together .touppercase , .tolowercase in if else statements.

public static void parsing(string name[]) { string temp = name[0]; int = 0; for(i = 0; < temp.length(); i++) { if(temp.charat(i) == 'a' || temp.charat(i) == 'a' || temp.charat(i) == 'e' || temp.charat(i) == 'e' || temp.charat(i) == 'i' || temp.charat(i) == 'i' || temp.charat(i) == 'o' || temp.charat(i) == 'o' || temp.charat(i) == 'u' || temp.charat(i) == 'u') { system.out.print(temp.charat(i).touppercase); }//obviously wrong don't know do. else { system.out.print(temp.charat(i).tolowercase); }//obviously wrong don't know do. }

to convert single character utilize methods character class:

system.out.print(character.touppercase(temp.charat(i))); system.out.print(character.tolowercase(temp.charat(i)));

java string character

No comments:

Post a Comment