Results 1 to 4 of 4
  1. #1
    jh7468 is offline Member
    Join Date
    Jan 2011
    Location
    Park Ridge, IL
    Posts
    10
    Rep Power
    0

    Unhappy 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!

  2. #2
    user0 is offline Senior Member
    Join Date
    Dec 2010
    Posts
    100
    Rep Power
    0

    Default

    Hi - you can use toUpperCase() just as you mentioned.
    Java Code:
    System.out.println("There was a person named " + name.toUpperCase());
    Best,
    --user0--

  3. #3
    charleyjoyce is offline Member
    Join Date
    Jan 2011
    Posts
    18
    Rep Power
    0

    Default

    have you checked the Strings API? There is indeed a toUpperCase() method.

  4. #4
    jh7468 is offline Member
    Join Date
    Jan 2011
    Location
    Park Ridge, IL
    Posts
    10
    Rep Power
    0

    Default

    Thanks a million - I knew I was close, but couldn't get over the hump. It works perfectly.

Similar Threads

  1. Changing Webpage's Input Values
    By Lawllerskates in forum New To Java
    Replies: 0
    Last Post: 05-16-2010, 03:26 AM
  2. Printing multiple user entries.
    By mConfused in forum Advanced Java
    Replies: 2
    Last Post: 04-09-2010, 01:44 PM
  3. Changing Scanner input type
    By mlad in forum New To Java
    Replies: 13
    Last Post: 03-18-2010, 05:22 PM
  4. Replies: 0
    Last Post: 12-12-2009, 12:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •