943,752 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1229
  • Java RSS
Feb 17th, 2007
0

help needed badly

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
talablink is offline Offline
21 posts
since Feb 2007
Feb 17th, 2007
0

Re: help needed badly

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.
Reputation Points: 20
Solved Threads: 6
Junior Poster in Training
Cudmore is offline Offline
74 posts
since Nov 2005
Feb 17th, 2007
0

Re: help needed badly

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: hey guys i need help to
Next Thread in Java Forum Timeline: word counter, frequency, percentage





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC