Results 1 to 4 of 4
- 01-16-2011, 04:48 AM #1
Member
- Join Date
- Jan 2011
- Location
- Park Ridge, IL
- Posts
- 10
- Rep Power
- 0
Changing USER input to caps when printing
I have a fine java program that asks the user a series of questions, then prints a story using these answers. For instance, one question I ask the user is for their name, and the story that prints is therefore about a person with that name. It works flawlessly as is, but my problem is this - if the user inputs "John" for their name, I now need this to print as "JOHN" in my story.
I list the Strings (name, age, etc); then I system.out.print the questions (what is your name?); then I system.out.println the story ("There was a person named" + name).
This prints out "There was a person named John", but I need it to print out "There was a person named JOHN".
This is a beginning level java program, and I'm wondering if there is a simple way to do this with toUpperCase or something of the like.
Many thanks!
- 01-16-2011, 04:54 AM #2
Senior Member
- Join Date
- Dec 2010
- Posts
- 100
- Rep Power
- 0
Hi - you can use toUpperCase() just as you mentioned.
Best,Java Code:System.out.println("There was a person named " + name.toUpperCase());--user0--
- 01-16-2011, 04:54 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 18
- Rep Power
- 0
have you checked the Strings API? There is indeed a toUpperCase() method.
- 01-16-2011, 05:07 AM #4
Member
- Join Date
- Jan 2011
- Location
- Park Ridge, IL
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
Changing Webpage's Input Values
By Lawllerskates in forum New To JavaReplies: 0Last Post: 05-16-2010, 02:26 AM -
Printing multiple user entries.
By mConfused in forum Advanced JavaReplies: 2Last Post: 04-09-2010, 12:44 PM -
Changing Scanner input type
By mlad in forum New To JavaReplies: 13Last Post: 03-18-2010, 04:22 PM -
speech redirection from one app to other; changing input from mic to socket
By johnyjj2 in forum New To JavaReplies: 0Last Post: 12-11-2009, 11:29 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks