codeimport java
Question
**Here is my codeimport java.util.Scanner;public class ParseStrings { public static void
main(String[] args) {
Scanner scnr = new Scanner (System.in);
Scanner inSS = null;
String userInput = “”;
String firstWord = “”;
String secondWord = “”;
boolean input = false;
while ( !input) {
System.out.println( “Enter input string: “);
userInput = scnr.nextLine();
if (userInput.equals(“q”)){
System.out.println (“n Error: No comma in string.”);
}else {
System.out.println(“First word: ” + userInput);
input = true;
if (userInput == (“q”)){
System.out.println( “Enter input string: “);
} else {
String[] userArray = userInput.split(“,”);
System.out.println(“First word: ” + userArray[0]);
System.out.println(“Second word:” + userArray[1]);
System.out.println();
}
}
}
return;
}
}
*** I am not able to complete 2nd section.
6.6 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:
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"
