Question: Goal: In this problem, you will write a Java application called StringApplication that uses a Scanner object to take inputs from the user. In particular,
Goal: In this problem, you will write a Java application called StringApplication that uses a Scanner object to take inputs from the user. In particular, the program will take in a String and two ints and return several statements. If the String is provided is Big Java Early Objects and the two ints provided are 0 and 5, then the expected output of the program should look as follows:
Enter a book title: Big Java Early Objects
The first character is 'B'. The first word is "Big".
The rest of title is "Java Early Objects".
Enter the starting position for a substring: 0
Enter the length for the substring: 5
The 5-char substring starting at index 0 is "Big J".
Instructions: Start a new BlueJ project called hw4c in the cs46a/homework/hw04 folder. In the BlueJ project, create another class called StringApplication (there is no starter code provided for this example). Fill in this class with the following:
1. Create a Scanner object, declare a String variable and two int variables
2. Ask the user to enter a book title
3. Read in one line of input for book title
4. Print the first character of the book title within single quotes
5. Print the first word of the book title within double quotes.
6. Print the rest of the book title without the space after the first word within double quotes
7. Ask the user to enter the starting position for a substring
8. Read in the starting position and store it in the first int variable
9. Ask the user to enter the length for the substring
10. Read in the length and store it in the second variable
11. Print the substring of the book title specified by the starting position and the length within double quotes
Other tips and guidelines:
You can have local variables as needed but only create one Scanner object.
You can assume that the book title has multiple words separated by single spaces, but no spaces at either end of the book title.
Do not use the try-catch statement or any parse statements.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
