Question & Answer: 5.6 Warm up: Parsing strings (Java)…..

Who said that learning must be a struggle?. Enjoy stress-free learning today!
Calculate your order
Pages (275 words)
Standard price: $0.00
So much stress and so little time? Our premium writers got you covered.
So much stress and so little time? Our premium writers got you covered.

5.6 Warm up: Parsing strings (Java)

(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt)

Examples of strings that can be accepted:

Jill, Allen

Jill , Allen

Jill,Allen

Ex:

Enter input string: Jill, Allen

(2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)

Ex:

Enter input string: Jill Allen
Error: No comma in string
Enter input string: Jill, Allen

(3) Extract the two words from the input string and remove any spaces. Store the strings in two separate variables and output the strings. (2 pts)

Ex:

Enter input string: Jill, Allen
First word: Jill
Second word: Allen

(4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts)

Ex:

Enter input string: Jill, Allen
First word: Jill
Second word: Allen


Enter input string: Golden , Monkey
First word: Golden
Second word: Monkey


Enter input string: Washington,DC
First word: Washington
Second word: DC


Enter input string: q

Expert Answer

 

Tested on Eclipse with Java-8

package stringclass;

import java.util.Scanner;

// TODO: Auto-generated Javadoc

/**

* The Class ParsingString.

* @author Lalchand Mali.

*/

public class ParsingString {

/**

* The main method.

*

* @param args the arguments

*/

public static void main(String[] args) {

String userInput;

Scanner input = new Scanner(System.in);

/**

* Taking input from user

*/

 

So much stress and so little time? We’ve got you covered. Get your paper proofread, edited or written from scratch within the tight deadline.

Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.
25+ Subjects
From Literature to Law – we have MA and Ph.D. experts in almost any academic discipline, for any task.
Any Paper
We can write, proofread, paraphrase, format, edit or rewrite your any paper, whether it’s a review or a term paper.
High Quality
All the papers we deliver to clients are based on credible sources and are quality-approved by our editors.
Fast Turnaround
Our writers can complete a standard essay for you within 1-3 hours and a part of a dissertation – in 2-5 days.
High Quality
All the papers we deliver to clients are based on credible sources and are quality-approved by our editors.
Next
Why Customers
Become Our Regulars
We put decades of writing experience to work for you and are passionate about helping you succeed. Let the figures tell our story!
10
Years in Writing Business
97%
Orders Delivered on Time
3,500+
Experts on Our Team
9/10
Report Better Grades
The paper was done to my satisfaction. Thnk you.
Paper was late
Wow! I should never have doubted you guys. Thank you for the excellent grade
Great work!
Excellent! Followed directions and completed a great paper
That's Why We Are Here 24/7
We are proud to say that we've scored a
96% customer satisfaction rate.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Get that paper done in two clicks.
Our premium writers got you covered!
Who said learning must be a struggle? Enjoy stress-free learning today.