• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

This was a program given as an assignment

 
kiruthigha rajan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42967
73
  • Likes 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21015
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic