Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a new class named StringDemo.java. This class will have a main() method that does the following: a. Instantiates and initializes a String object

1. Create a new class named StringDemo.java. This class will have a main() method that does the following:

a. Instantiates and initializes a String object named myLastName (should be initialize to your last name)

b. That displays in a sentence the length of your last name (using the appropriate String method)

c. Declares an integer named secondLastLetter that is equal to 2 less than the length of your last name.

d. Uses the appropriate String method to display your second-to-last character of your last name (in a complete sentence).

e. Uses the appropriate String method to display your last name all in Upper Case letters.

f. Has an if statement that compares your last name to the string Short, and displays whether or not you have the same last name as your professor.

g. Has an if statement that determines whether your last name contains the character sequence ne. If your last name contains ne a statement should state that your last name (display it) contains the character sequence ne, or it should say that it does not. e.g. Display for the instructor will be: The last name Short does not contain ne

h. Please take notice of the double quotes. Note: Google the Java API to find which method checks for character sequences in a String object.

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_2

Step: 3

blur-text-image_3

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

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago