This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Java character input and modification. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java character input and modification." Watch "Java character input and modification." New topic
Author

Java character input and modification.

Ben Peer
Greenhorn

Joined: Apr 21, 2010
Posts: 15
I can't figure out how i can apply the methods like S1.toLowerCase () or S1.toUpperCase ().



This is what i have

This is what it needs to do

Write a Java program that asks the user to enter characters, one at a time, from the command line. The program should end when the period (".") character is entered and the number of case changes that occurred should be displayed. As each character is entered, the program
o should change each lower case character to upper case after it is entered.
o should change each upper case character to lower case after it is entered.
o should output the resulting change to the monitor after each character is input.
o should not make any changes to other characters such as @ or $).
o should instruct the user to enter the period (.) character to end the program.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20078
    
  30

Check out String.length(), String.charAt(i) and the static methods of class java.lang.Character.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43935
    
  33
Never write == true or == false. If you need something to be false, use the bang operator !

Have you come across the read() method of the Reader classes, which reads one character at a time. It is usually a method I would avoid, but you have been told to read single characters. So read() might be what you want, and you can then set up a while loop to test whether you have reached a . yet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java character input and modification.
 
It's not a secret anymore!