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
Describe Mr. Digby, the principal. ​
Gennadij [26K]

Answer:

stinky

Explanation:

7 0
4 years ago
Using Turtle Graphics, write a program that will produce 2 Zs next to each other. It is irrelevant where these Zs appear and wha
LekaFEV [45]

Answer:

# import the  turtle library

from turtle import *

# create a turtle space

space = Screen()

# create a turtle object

z = Turtle()

 

# create a single Z

z.forward(50)

z.right(120)

z.forward(100)

z.left(120)

z.forward(50)

 

# adjust the turtle position

z.up()

z.left...

Explanation:

8 0
3 years ago
Task 03
Kamila [148]

Answer:

class Program {

 public static void Main (string[] args) {

   double number = 1.0;

   while(number >= 0.001) {

     Console.WriteLine (number);

     number /= 2;

   }    

 }

}

Explanation:

Always think carefully about what is in the condition of the while statement. In this case, you want the loop to be executed as long as the number is larger than or equal to 0.001.

3 0
2 years ago
If ten men can build a card in one week, how long does it take to 50 men?
velikii [3]
Not sure, 5 weeks? I'm sorry if it's incorrect.
4 0
3 years ago
a __________ uses software and/or hardware to prevent unwanted access to a computer or computer system.
Crank
Anti virus software
6 0
3 years ago
Other questions:
  • Which of the following statements is false?
    10·1 answer
  • In this question, we give two implementations for the function: def intersection_list(lst1, lst2) This function is given two lis
    15·1 answer
  • You've been hired as a consultant to help an online store owner. You need to complete the implementation of conversion tracking
    5·1 answer
  • Which field can be used to track the progress on tasks that a user has created?
    10·1 answer
  • How can i become an expert in computer and technology?
    15·2 answers
  • An app builder wants to show groups as the last navigation menu item in the Salesforce1 mobile app. However, the app builder is
    8·1 answer
  • 3. Find the product of (a² +3a+5) x (a+7)​
    7·1 answer
  • Which of the following is the definition of registration authority ( RA)?
    10·1 answer
  • Why can it be helpful to perform mathematical calculations using programming? Choose the best answer.
    11·1 answer
  • besides entering a url to go directly to a website, what else can you enter in a browser address bar to explore the internet?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!