ITEC 120 LAB 6 Back to Lab index page

String methods

You will write Java program that will call a bunch of different String methods.

First, your program will ask the user to input a String.

Next, your program will output the original string (surrounded by "s), the length of the string, the first character in the string, the last character in the string, the string in all lowercase letters, the string in all uppercase letters, the original string with all of the first characters replaced by the last character.

For this lab, try to make your output look exactly as shown (using tabs and blank lines) so that it is readable.

Sample run:
Program outputs:

Please type a string:

User inputs: all I wanna do is code Java!
Program outputs:

You typed:       "all I wanna do is code Java!".
Your string is   28 characters long.

The first character is: a
The last character is:  !

All lowercase:    all i wanna do is code java!
All uppercase:    ALL I WANNA DO IS CODE JAVA!

Replacing all the as with !s :
                  !ll I w!nn! do is code J!v!!

Once you have your program working, show your lab to the Peer Instructor to be checked off. You'll run your program a couple times for the Peer Instructor.