subject

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
must use this as part of the solution:
import java. util. Scanner;
public class ParseStrings {
public static void main(String[] args) {
/* Type your code here. */
Scanner scnr = new Scanner(System. in);
String lineString = "";
String firstName;
String lastName;
boolean inputDone;
System. out. println("Enter input string: ");
lineString = scnr. nextLine();
while (lineString. indexOf(',') == -1){
System. out. println("Error: No comma in string");
System. out. println("Enter input string: ");
lineString = scnr. nextLine();
inSS = new Scanner(userInfo);
// Parse name and age values from string
firstName = inSS. next();
lastName = inSS. next();
}
return;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:00
Competent nonverbal communication involves interacting with others in a manner that is appropriate for which of the following? select all that apply. situation task individuals
Answers: 3
question
Computers and Technology, 22.06.2019 23:50
List a few alternative options and input and output over the standerd keyboard and monitor. explain their functioning in details.
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
*! 20 points! *jeff wants to create a website with interactive and dynamic content. which programming language will he use? a. dhtml b. html c. css d. javascript
Answers: 1
question
Computers and Technology, 24.06.2019 06:00
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
Parsing strings (Java) (1) Prompt the user for a string that contains two strings separated by a co...
Questions
question
Social Studies, 19.03.2021 19:10
question
Mathematics, 19.03.2021 19:10
question
Mathematics, 19.03.2021 19:10
question
Mathematics, 19.03.2021 19:10
question
English, 19.03.2021 19:10
Questions on the website: 13722360