This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes This was a program given as an assignment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "This was a program given as an assignment" Watch "This was a program given as an assignment" New topic
Author

This was a program given as an assignment

kiruthigha rajan
Ranch Hand

Joined: Dec 29, 2011
Posts: 69
write a java program that should change the case of every second character to the upper case and print them
for instance:input:hello world
output should be:hElLo WoRlD
please give the code
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41064
    
  43
So you want us to do your assignment for you? Will we get the credit for it as well? Or were you thinking of paying us?


Ping & DNS - my free Android networking tools app
kiruthigha rajan
Ranch Hand

Joined: Dec 29, 2011
Posts: 69
Ulf Dittmer wrote:So you want us to do your assignment for you? Will we get the credit for it as well? Or were you thinking of paying us?

excuse me.. it was not assigned for me..i saw this on a book..i tried out of curiosity.. i couldnt get..i just asked help so that i can learn.. [DELETED]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18507
    
  40

kiruthigha rajan wrote:write a java program that should change the case of every second character to the upper case and print them
for instance:input:hello world
output should be:hElLo WoRlD
please give the code



FYI... the example shown doesn't capitalize every second character. For the second word, it capitalize everything but the second letter. Never mind. I see now. It is capitalizing every other letter -- and not the second letter of each word.

Also, IMO, this is something that can be simply done via a regular expression. It can still easily be done via regular expressions, but definitely more awkward.

Henry

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: This was a program given as an assignment
 
Similar Threads
Why is that SCJP costs around Rs5000 to Rs7000 in India and costs 300$(around Rs25000) in Pakistan ?
chars using the + operator
Java Chess Game I made by my self
stand alone
KB 791