It's not a secret anymore!
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
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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
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?
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: 20057
    
  44

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)
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: This was a program given as an assignment
 
It's not a secret anymore!