/** * A Java program to input strings and call methods strings. * * Note: Codecheck will use different input values to test * the program, and you must use the specified variables in * your program. 7 8 * * Step 2: Enter your name for @author and today's date for @version * @author * @version */ 10 11 12 13 14 public class StringProg 15 16 public static void main(String [] args) 17 18 // Step 3: Create a new Scanner object 19 20 21 // Step 4: Display a prompt "Enter multiple words separated by single spaces: 22 23 24 // Step 5: Read in one line of input and store it in a variable line 25 26 27 // Step 6: Display line on one line within double quotes 28 // with message "The original line: " 29 30 31 // Step 7: Trime spaces from both ends of line and save it back to line 32 33 34 // Step 8: Display line on one line within double quotes 35 // with message "The line with spaces trimmed from both ends: 36 37 38 // Step 9: Ask for a word with prompt "Enter a single word: " 39 40 41 // Step 10: Read in a single string and store it in variable word 42 43 44 // Step 11: Display word on one line within double quotes Restricted Mode

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
icon
Related questions
Question
2
3
/**
4
* A Java program to input strings and call methods strings.
* Note: Codecheck will use different input values to test
* the program, and you must use the specified variables in
* your program.
7
8
*
* Step 2: Enter your name for @author and today's date for @version
* @author
* @version
*/
10
11
12
13
public class StringProg
{
public static void main(String [) args)
14
15
16
17
18
1 // Step 3: Create a new Scanner object
19
20
21
// Step 4: Display a prompt "Enter multiple words separated by single spaces: "
22
23
24
// Step 5: Read in one line of input and store it in a variable line
25
26
// Step 6: Display line on one line within double quotes
with message "The original line: "
27
28
//
29
30
31
// Step 7: Trime spaces from both ends of line and save it back to line
32
33
34
// Step 8: Display line on one line within double quotes
35
//
with message "The line with spaces trimmed from both ends: "
36
37
38
// Step 9: Ask for a word with prompt "Enter a single word: "
39
40
41
// Step 10: Read in a single string and store it in variable word
42
43
44
// Step 11: Display word on one line within double quotes
O 0 AO
O Restricted Mode
МacВook Air
esc
80
F1
F2
F3
F4
F5
F6
Transcribed Image Text:2 3 /** 4 * A Java program to input strings and call methods strings. * Note: Codecheck will use different input values to test * the program, and you must use the specified variables in * your program. 7 8 * * Step 2: Enter your name for @author and today's date for @version * @author * @version */ 10 11 12 13 public class StringProg { public static void main(String [) args) 14 15 16 17 18 1 // Step 3: Create a new Scanner object 19 20 21 // Step 4: Display a prompt "Enter multiple words separated by single spaces: " 22 23 24 // Step 5: Read in one line of input and store it in a variable line 25 26 // Step 6: Display line on one line within double quotes with message "The original line: " 27 28 // 29 30 31 // Step 7: Trime spaces from both ends of line and save it back to line 32 33 34 // Step 8: Display line on one line within double quotes 35 // with message "The line with spaces trimmed from both ends: " 36 37 38 // Step 9: Ask for a word with prompt "Enter a single word: " 39 40 41 // Step 10: Read in a single string and store it in variable word 42 43 44 // Step 11: Display word on one line within double quotes O 0 AO O Restricted Mode МacВook Air esc 80 F1 F2 F3 F4 F5 F6
// Step 12: Trime spaces from both ends of word and save it back to word
// Step 13: Display word on one line within double quotes
//
with message "The word with spaces trimmed from both ends: "
// Step 14: Find out if line contains word and assign
the result to a variable true0rFalse
//
// Step 15: Display the value of trueOrFalse on one line
with message "The line contains the word: "
//
// Step 16: Find out the index of word within line and assign
the result to an integer variable pos
//
// Step 17: Display the value of pos on one line
//
with message "The index of word in line: "
// Step 18: Find out the index of the first space
within line and assign it to pos
//
// Step 19: Display the first word of line on one line
within double quotes with message
//
//
"First word of line: "
// Step 20: Find out the index of the second space within
line and assign it to another int variable
//
// Step 21: Display the second word of line
within double quotes with message
//
//
"Second word of line: "
Transcribed Image Text:// Step 12: Trime spaces from both ends of word and save it back to word // Step 13: Display word on one line within double quotes // with message "The word with spaces trimmed from both ends: " // Step 14: Find out if line contains word and assign the result to a variable true0rFalse // // Step 15: Display the value of trueOrFalse on one line with message "The line contains the word: " // // Step 16: Find out the index of word within line and assign the result to an integer variable pos // // Step 17: Display the value of pos on one line // with message "The index of word in line: " // Step 18: Find out the index of the first space within line and assign it to pos // // Step 19: Display the first word of line on one line within double quotes with message // // "First word of line: " // Step 20: Find out the index of the second space within line and assign it to another int variable // // Step 21: Display the second word of line within double quotes with message // // "Second word of line: "
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education