This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hey guys, I'm trying to make a program that modifies an input string (via JOptionPane.showInputDialog) so that the first character of a word is always capitalized and every other character is in lowercase. For instance if I inputted "hey yall" the program should output "Hey Yall". So far I've made it so that this works so long as the first character is a letter. However the code I've written doesn't work if the first character is a non letter character (such as _ ). So if I input "_hey yall" the output looks like "_hey Yall". This is a school project, so I understand if you don't want to give me the answer directly, but your help in this matter would be greatly appreciated!
I don't have any suggestions off the top of my head to answer your question directly. However, I have a suggestion to help make your code more readable: use character constants rather than ASCII values. By this I mean that instead of using the number 32, you should use the character literal ' '; instead of 97, use 'a'. (Character constants are simply a single character surrounded by single quotes.) Not only will it help others here to understand your code, but if you come back to this at a later time, YOU will be able to more easily understand what you did.
Also, when you post code, you should use UBB CODE tags. There are shortcut buttons below the text area where you type a message for this forum.
I'm sorry that I can't answer your question more directly, but perhaps if you make this change it may help you find the problem on your own.