help needed badly

Reply

Join Date: Feb 2007
Posts: 19
Reputation: talablink is an unknown quantity at this point 
Solved Threads: 1
talablink's Avatar
talablink talablink is offline Offline
Newbie Poster

help needed badly

 
0
  #1
Feb 17th, 2007
Hello I need help. I need to write a program that changes all upper case letters to lower case letters and all lower case letters to upper case then the vowels with an *...

it would look like this

normal= UppER loweR caSe

output should be this..

*PP*r L*W*r C*s*..

i already know how to change all lower case to upper case and vice versa if it's a sentence..but i don't know how to do it per letter..

can anyone pls help me..:cheesy:plzzzzz
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 74
Reputation: Cudmore is an unknown quantity at this point 
Solved Threads: 5
Cudmore's Avatar
Cudmore Cudmore is offline Offline
Junior Poster in Training

Re: help needed badly

 
0
  #2
Feb 17th, 2007
You have to analyze the input one character at a time...
Say we have a string: myString

Set up a for loop with a lower limit of 0 and an upper limit of myString.length()-1 inclusive

Read each character one at a time with myString.charAt(int index)

Analyze the single character. What is it? A vowel? Upper-case? Lower-case?

Append the new character to another string / a buffer.

Next character in the loop...
There are other ways to do this, but the above should work for general purpose.
Last edited by Cudmore; Feb 17th, 2007 at 10:57 am.
synchronized (theWorld) { System.out.println ("It's all mine..."); }
How many people have code in their Sigs?
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: help needed badly

 
0
  #3
Feb 17th, 2007
Easiest (and fastest) is to use regular expressions to replace all uppercase letters with an asterisk, then call toUppercase() on the resulting string.
Far more elegant (and possibly faster, especially with long strings) than looping through every character.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC