Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java. Using the following String methods Create a new class with a main method called StringExperiment.java Declare three String variables called: firstName, middleName, and lastName.

Java. Using the following String methods

image text in transcribed

Create a new class with a main method called StringExperiment.java

Declare three String variables called: firstName, middleName, and lastName. Initialize each with your names

Do each of the following:

a. Print your full name with a space between each name. Example: First Middle Last

b. Print your first name, middle initial followed by a period, and last name. Example: First M. Last

c. Print your first name in all uppercase letters and last name in all lowercase letters.

d. Print the length of your last name. Be sure to give it a label.

e. Calculate the middle position in your last name and print the letter that is there. If your name has an even number of letters, it will be one to the right of the middle.

f. Print the last letter in your first name.

charAt public char charAt (int index) Returns the char value at the specified index indexOf public int indexof (String str) Returns the index within this string of the first occurrence of the specified character lastlndexOf public int lastIndexof (String str) Returns the index within this string of the last occurrence of the specified substring length public int length) Returns the length of this string substring public String substring (int beginIndex) Returns a new string that is a substring of this string. public String substring (int beginIndex, int endIndex) Returns a new string that is a substring of this string toLowerCase public String toLowerCase ) Converts all of the characters in this String to lower case toUpperCase public String toUpperCase () Converts all of the characters in this String to upper case

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions