Question: JAVA________What am i missing???And were does it go???? My CODE!!!!! import java.util.Scanner; public class ParseStrings { public static void main(String[] args) { Scanner keyboard =
JAVA________What am i missing???And were does it go????
My CODE!!!!! import java.util.Scanner;
public class ParseStrings {
public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); String s, first, last; while (true) { System.out.print(" Enter input string: "); s = keyboard.nextLine(); // checks if user enter q or Q if(s.compareTo("q") == 0 || s.compareTo("Q") == 0) break; // stop and exit the program while (s.indexOf(",") == -1) { // checks if any comma is present System.out.println("Error: No comma in string"); System.out.print("Enter input string: "); s = keyboard.nextLine(); } // extract the first word first = s.substring(0, s.indexOf(",")).trim(); // extract the lsat word last = s.substring(s.indexOf(",") + 1, s.length()).trim(); System.out.println("First word: " + first); System.out.println("Second word: " + last); } return; } }
Final output!!!

![public class ParseStrings { public static void main(String[] args) { Scanner keyboard](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f39e8039238_85566f39e7fc599b.jpg)


1. Compare output Jill, Allen Input Your output starts with Enter input string: Fi Expected output starts with Enter input string: 2. Compare output 0/2 Jill Allen JillAllen Input Jill Allen Enter input string: Error: No comma in string Enter input string: Error: No comma in string Your output starts with Enter input string: Error: No comma in string Enter input string: Error: No comma in string Enter input string: Exc Enter input string: Error: No comma in string Enter input string: Error: No comma in string Expecte d output starts with Enter input string Error: No comma in string Enter input string
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
