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.
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.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F170cb9b5-2292-4ecc-9f24-3c60291ff66d%2Fb7fc7064-97bf-492b-90e1-d84d80c5ea81%2Fcv0osq_processed.jpeg&w=3840&q=75)
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F170cb9b5-2292-4ecc-9f24-3c60291ff66d%2Fb7fc7064-97bf-492b-90e1-d84d80c5ea81%2Frc1siqc_processed.jpeg&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
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:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education