Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

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"