Introduction to Java using NetBeans
Section 2 - Using String Data
As we saw in the previous section a String is any group of characters that is enclosed in quotes.
Every character in a string has an index position in the string (an integer). The index position of the first character is 0.
Below are lines of code that make use of string methods. Try to figure out what each line of code will print and then check your answers by typing up the code.
Check Your Understanding
Assignment 2.6 String Manipulation
Create an application that asks the user for their first, middle and last names and stores them in a single string
is your Name?
Display the name using the formats:
1. "Your name
in reverse order is Lastname, Firstname " in an appropriate
" in an appropriate message box
HINT: Find the position of the spaces and then use substring
2. Display the number of characters in the name, firstname, and lastname, not including spaces.
" There are 17 characters in your fullname"
" There are 9 characters in your firstname"
" There are 8 characters in your lastname"
Remember that the program must work no matter what name is entered.
4. Regardless of how the name is entered (upper, lower, combination) display the names with upper case first letters and lower case everything else.
5. Make everything work if First Middle Last names are entered.
3. Display the entire name in Upper Case Letters
4. Display the entire name in Lower Case Letters
Posting your work
1. Upload the Java Projects to your Gravelle Folder (Share with me only) and put a link for each assignment on your website.
JAR files which are executable java files do not work on projects without a display so we will not use them in this assignment.