Question
SPECIFICATIONS: Class Name: StringLab02.java These if-else statements should be contained in a separate method that is called by the main method. If/Else-Statements: Use if and/or
SPECIFICATIONS:
- Class Name: StringLab02.java
- These if-else statements should be contained in a separate method that is called by the main method.
- If/Else-Statements: Use if and/or if/else-statements in the program.
- Run Once: Note that the sample output shows many different outcomes bymany different program-executions. Only one menu item (with appropriate user-defined input parameters) will be performed per program-execution.
- Default: Include a default message ("Not a valid number!") if the user chooses an invalid menu-option.
NOTES:
|
SAMPLE OUTPUT:
==================================================
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 1
The length of the phrase is 14
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 2
Enter a number between 0 and 13: 8
The character at index 8 is 'a' ==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 3
Enter a phrase that will be compared with "this is a test": this is a test
The two phrases DO have the same sequence of characters.
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 3
Enter a phrase that will be compared with "this is a test": this is NOT a test
The two phrases DO NOT have the same sequence of characters.
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 4
Enter a phrase that will be compared with "this is a test": this is a test
The two phrases are equivalent.
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 4
Enter a phrase that will be compared with "this is a test": abc
Alphabetically, "this is a test" comes after "abc"
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 4
Enter a phrase that will be compared with "this is a test": xyz
Alphabetically, "this is a test" comes before "xyz"
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 5
Enter a String to search "this is a test" for: hi
The first occurrence of "hi" is at index 1
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 5
Enter a String to search "this is a test" for: zzz
"zzz" is not in the phrase "this is a test"
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 6
Choose one of the methods:
1. Compose a substring from a selected index until the end,2. Compose a substring from a selected index until another selected index
Enter selection: 1
Which index (between 0 and 13) would you like to start with? 10
The new phrase is: "test"
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 6
Choose one of the methods:
1. Compose a substring from a selected index until the end,2. Compose a substring from a selected index until another selected index
Enter selection: 2
Which index (between 0 and 13) would you like to start with? 2
Which index (between 2 and 13) would you like to end with? 7
The new phrase is: "is is"
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 7
All lowercase looks like this: "this is a test"
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 8
All uppercase looks like this: "THIS IS A TEST"
==========
Please enter a phrase: this is a test
- Find the length of the string
- Perform charAt
- Perform equals
- Perform compareTo
- Perform indexOf
- Perform substring
- Perform toLowerCase
- Perform toUpperCase
Please make a selection: 42
Not a valid number!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started