1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
DIA [1.3K]
4 years ago
7

(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
Computers and Technology
1 answer:
GalinKa [24]4 years ago
5 0

package parsestrings;

import java.util.Scanner;

public class ParseStrings {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in); // Input stream for standard input

Scanner inSS = null; // Input string stream

String lineString = ""; // Holds line of text

String firstWord = ""; // First name

String secondWord = ""; // Last name

boolean inputDone = false; // Flag to indicate next iteration

// Prompt user for input

System.out.println("Enter input string: ");

// Grab data as long as "Exit" is not entered

while (!inputDone) {

// Entire line into lineString

lineString = scnr.nextLine()

// Create new input string stream

inSS = new Scanner(lineString);

// Now process the line

firstWord = inSS.next();

// Output parsed values

if (firstWord.equals("q")) {

System.out.println("Exiting.");

inputDone = true;

if (firstWord.matches("[a-zA-Z]+,[a-zA-Z]+")) {

System.out.print("Input not two comma separated words");

}

} else {

secondWord = inSS.next();

System.out.println("First word: " + firstWord);

System.out.println("Second word: " + secondWord);

System.out.println();

}

}

return;

}

}

You might be interested in
A key part of running a business blog is ensuring it, and by extension the organization’s website are easily discoverable. Make
blondinia [14]

Answer:

SEO Friendly

Explanation:

Making websites SEO Friendly refers to design styles that makes search engines to easily find contents on the website. The search engines can easily find content on individual page of the website efficiently and interpret effectively.

3 0
4 years ago
How do you type multiple lines of code into IDLE? My Python environment does not look like the one projected in the lectures. I
natulia [17]
<span> The OSX IDLE provides the functionality of typing multiple lines of the code.  You can find the IDLE environment easily over the internet. </span><span />
5 0
4 years ago
We are supposed to go to the concert tomorrow, but it has been raining for three days straight. I just know that we won’t be abl
Mumz [18]

Its the worried tone

Hope this helps!

3 0
3 years ago
Read 2 more answers
Print either "fruit", "drink", or "unknown" (followed by a newline) depending on the value of useritem. print "unknown" (followe
kenny6666 [7]
According to your syntax, I am pretty sure that this one is C++ question. I think that your solution looks like this:
So if useritem is gr_apples, output should be "Fruit".
int main() {   enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER};
   GroceryItem userItem = GR_APPLES; if((userItem == GR_APPLES) || (userItem == GR_BANANAS)){ cout << "Fruit"; } else if((userItem == GR_JUICE) || (userItem == GR_WATER)){ cout << "Drink"; } else{ cout << "Unknown"; }
cout << endl;   return 0;}
5 0
3 years ago
Read 2 more answers
Fill in blanks The character which is not found on a standard keyboard is called _______ Charater.​
deff fn [24]

Answer:

The character which is not found on a standard keyboard is called __symbol_____ Charater

Explanation:

7 0
3 years ago
Other questions:
  • Locker doors There are n lockers in a hallway, numbered sequentially from 1 to n. Initially, all the locker doors are closed. Yo
    15·1 answer
  • Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?
    15·1 answer
  • You have compiled a new kernel using rpm. when you reboot, the new kernel is not the default selection on the boot menu. you use
    10·1 answer
  • What two programming systems uses numbers and text?
    6·1 answer
  • An accompanying ____ gives audience members reference notes and review material for your presentation.
    6·1 answer
  • Which value can be entered to cause the following code segment to display the message: "That number is acceptable." int number;
    11·1 answer
  • Given a number count the total number of digits in a number
    12·1 answer
  • I need help ASAP please and thank you!
    6·1 answer
  • Prepare a document to list down at least 10 features/operations (on process and thread) you can do using Process Explorer.
    15·1 answer
  • Help pweeze this is due today :(<br><br> I will give u brainliest just pweeze, I need this answer :(
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!