User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 426,197 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,839 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 828 | Replies: 2
Reply
Join Date: Feb 2007
Location: Phil..
Posts: 18
Reputation: talablink is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
talablink's Avatar
talablink talablink is offline Offline
Newbie Poster

help needed badly

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2005
Posts: 72
Reputation: Cudmore is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Cudmore's Avatar
Cudmore Cudmore is offline Offline
Junior Poster in Training

Re: help needed badly

  #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 9:57 am.
synchronized (theWorld) { System.out.println ("It's all mine..."); }
How many people have code in their Sigs?
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 199
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: help needed badly

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 6:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC