Write a Java program StringProg which creates a Scanner and then does the following: 1. Ask the user to enter their full name using prompt "Enter your full name: ". 2. Get the full name and store it in a variable. The full name could have several words separated by single spaces with possible one or more spaces at both sides. 3. Ask the user to enter an integer as the starting index for a substring using prompt "Enter an integer as the starting index for a substring: ". 4. Get the integer and store it in a variable.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
- used multiple Scanner objects • - use substring() to get the first char • use charAt() to get the last char
6. Get the integer and store it in a variable.
7. Print the input full name on one line with double quotes.
8. Trim spaces from the input full name and store it back to the same variable.
9. Print the input full name after trimming on one line with double quotes.
10. Print the substring specified by the starting index and the substring length with double
quotes. You can assume the input values are valid to get a substring.
11. Print the first character of the full name with single quotes. Use the substring() method.
12. Print the last character of the full name with single quotes. Use the charAt() method.
13. Print just the first name, the substring from the beginning up to but excluding the first
space, with double quotes.
14. Print the rest of the name with double quotes. Do not include the space after the first
name.
Sample output
Enter your full name: Gary Payton II
Enter an integer as the starting index for a substring: 1
Enter an integer as the substring length: 2
The input full name is "Gary Payton II ".
The input full name after trimming spaces is "Gary Payton II".
The 2-char substring starting at index 1 is "ar".
The first character is 'G'.
The last character is 'I'.
The first name is "Gary".
The rest of name is "Payton II".
You should create just one Scanner object.
Codecheck link for Problem C
Transcribed Image Text:6. Get the integer and store it in a variable. 7. Print the input full name on one line with double quotes. 8. Trim spaces from the input full name and store it back to the same variable. 9. Print the input full name after trimming on one line with double quotes. 10. Print the substring specified by the starting index and the substring length with double quotes. You can assume the input values are valid to get a substring. 11. Print the first character of the full name with single quotes. Use the substring() method. 12. Print the last character of the full name with single quotes. Use the charAt() method. 13. Print just the first name, the substring from the beginning up to but excluding the first space, with double quotes. 14. Print the rest of the name with double quotes. Do not include the space after the first name. Sample output Enter your full name: Gary Payton II Enter an integer as the starting index for a substring: 1 Enter an integer as the substring length: 2 The input full name is "Gary Payton II ". The input full name after trimming spaces is "Gary Payton II". The 2-char substring starting at index 1 is "ar". The first character is 'G'. The last character is 'I'. The first name is "Gary". The rest of name is "Payton II". You should create just one Scanner object. Codecheck link for Problem C
Problem C
Write a Java program StringProg which creates a Scanner and then does the following:
1. Ask the user to enter their full name using prompt "Enter your full name: ".
2. Get the full name and store it in a variable. The full name could have several words
separated by single spaces with possible one or more spaces at both sides.
3. Ask the user to enter an integer as the starting index for a substring using prompt "Enter
an integer as the starting index for a substring: ".
4. Get the integer and store it in a variable.
5. Ask the user to enter an integer as the length for the substring using prompt "Enter an
integer as the substring length: ".
ok Air
DI
DD
F7
F8
F9
F10
F11
F12
*
)
9.
{
}
P.
[
]
%3D
K
令
+||
08
Transcribed Image Text:Problem C Write a Java program StringProg which creates a Scanner and then does the following: 1. Ask the user to enter their full name using prompt "Enter your full name: ". 2. Get the full name and store it in a variable. The full name could have several words separated by single spaces with possible one or more spaces at both sides. 3. Ask the user to enter an integer as the starting index for a substring using prompt "Enter an integer as the starting index for a substring: ". 4. Get the integer and store it in a variable. 5. Ask the user to enter an integer as the length for the substring using prompt "Enter an integer as the substring length: ". ok Air DI DD F7 F8 F9 F10 F11 F12 * ) 9. { } P. [ ] %3D K 令 +|| 08
Expert Solution
Step 1

As per the answering policy i can only answer upto 3 question max at a time, so I'm answering first three, for rest please upload your question specifically.

 

Program:

Computer Science homework question answer, step 1, image 1

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT