Problem Description. Arguments for the main method are passed as strings. Strings enclosed in quotation marks are considered as one argument. Write a program to parse arguments from a string. Arguments are separated by spaces. Enclosed strings are considered as one argument. Your program should prompt the user to enter a string and display the arguments, each per line, as shown in the following sample run. Enter the arguments: a friend "good morning" "good afternoon" b   a friend good morning good afternoon b please provide the answer in JAVA

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

Problem Description. Arguments for the main method are passed as strings. Strings enclosed in quotation marks are considered as one argument. Write a program to parse arguments from a string. Arguments are separated by spaces. Enclosed strings are considered as one argument. Your program should prompt the user to enter a string and display the arguments, each per line, as shown in the following sample run.

<input>

Enter the arguments: a friend "good morning" "good afternoon" b

 

<output>

a

friend

good morning

good afternoon

b

please provide the answer in JAVA

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

the code is not working please can you check again ? 

AutoSave (● Off)
Ans
AlgoDesign src C Main
Bookmarks
ucture
File Edit View Navigate Code
m main
■OHE
Run:
>
Project
AlgoDesign C:\Users\Piincher\IdeaProjects\AlgoDesign
.idea
out
5phyZving
>
META-INF
Main
AlgoDesign.iml
> III External Libraries
src
↑
artifacts
→ 16
AlgoDesign_jar
production
Scratches and Consoles
Version Control ▶ Run
TODO
All files are up-to-date (moments ago)
R021905-\/TRAI||| V
Refactor Build Run Tools VCS Window Help
Type here to search
℗ Problems
1
2
good.png
6
7
8
9
ERGREREE
10
11
12
13
14
15
16
17
Main.java
A
A
A
e
밥
O
Search (Alt+0)
import java.util.*;
2 usages
public class Main
> Terminal ▸ Services
{
Ĥ public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
AlgoDesign.jar - Main.java
String str = sc.nextLine();
for(int i=0; i < str.length(); i++){
if(str.charAt(i) == ''){
System.out.println();
}
else if(str.charAt(i) == '"''){
Profiler
for(int j=i+1; j < str.length(); j++){
if(str.charAt(j) == '"'){
i =j+1;
Main X
Program Files\JetBrains\IntelliJ IDEA 2022.2.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Piincher\IdeaProjects\AlgoDesign\out\production\AlgoDesign Main
Show all
H
Build
X
W
Main ▾
19
Sign in
ĠÁCa
■
□Ơ
Q ▸
10:45 CRLF UTF-8 4 spaces
74°F Partly cloudy. 4) ENG
))) Database
Notifications
V
lace
Share
ct ✓
7:55 AM
9/3/2022
X
100%
Transcribed Image Text:AutoSave (● Off) Ans AlgoDesign src C Main Bookmarks ucture File Edit View Navigate Code m main ■OHE Run: > Project AlgoDesign C:\Users\Piincher\IdeaProjects\AlgoDesign .idea out 5phyZving > META-INF Main AlgoDesign.iml > III External Libraries src ↑ artifacts → 16 AlgoDesign_jar production Scratches and Consoles Version Control ▶ Run TODO All files are up-to-date (moments ago) R021905-\/TRAI||| V Refactor Build Run Tools VCS Window Help Type here to search ℗ Problems 1 2 good.png 6 7 8 9 ERGREREE 10 11 12 13 14 15 16 17 Main.java A A A e 밥 O Search (Alt+0) import java.util.*; 2 usages public class Main > Terminal ▸ Services { Ĥ public static void main(String[] args) { Scanner sc = new Scanner(System.in); AlgoDesign.jar - Main.java String str = sc.nextLine(); for(int i=0; i < str.length(); i++){ if(str.charAt(i) == ''){ System.out.println(); } else if(str.charAt(i) == '"''){ Profiler for(int j=i+1; j < str.length(); j++){ if(str.charAt(j) == '"'){ i =j+1; Main X Program Files\JetBrains\IntelliJ IDEA 2022.2.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Piincher\IdeaProjects\AlgoDesign\out\production\AlgoDesign Main Show all H Build X W Main ▾ 19 Sign in ĠÁCa ■ □Ơ Q ▸ 10:45 CRLF UTF-8 4 spaces 74°F Partly cloudy. 4) ENG ))) Database Notifications V lace Share ct ✓ 7:55 AM 9/3/2022 X 100%
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Methods of StringBuilder class
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