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]
3 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]3 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
What is a sound wave
solmaris [256]

Answer:

A wave of sound!

Explanation:

sound waves are sound but sound comes in different wavelengths

7 0
3 years ago
Read 2 more answers
Which of the following steps should you take after attending a college fair?
leonid [27]

D. Make a decision about which colleges to attend that night.

5 0
3 years ago
Read 2 more answers
Write a recursive function to compute sum of first N integers starting with 1.
Citrus2011 [14]

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// recursive function to find sum from 1 to n

int recur_Sum(int n)

{ // base condition

if (n <= 1)

 return n;

// recursive call

return n + recur_Sum(n - 1);

}

// main function

int main()

{

   // variables

   int n;

   cout<<"Enter a number:";

   // read the number

   cin>>n;

   // print the sum

   cout<<"Sum of first "<<n<<" integer from 1 to "<<n<<" is:"<<recur_Sum(n);

return 0;

}

Explanation:

Read a number from user and assign it to variable "n".Call function recur_Sum() with parameter "n".This function will recursively call itself and find the Sum of first n numbers from 1 to n.Then function will return the sum.

Output:

Enter a number:10

Sum of first 10 integer from 1 to 10 is:55

4 0
3 years ago
You
N76 [4]

Answer: A

Explanation: the process or action of verifying the identity of a user or process.

Hope this helps ^.^

8 0
3 years ago
Read 2 more answers
I WILL GIVE BRAINLIEST!!! PLEASE HELP ME! Mitchell runs a successful delivery service. His business has expanded and he must hir
IgorLugansk [536]

Answer:

Mitchell ought to use telephone.

Explanation:

Because telephone is a common telecommunication garget which he can use to reach his client s easy.

3 0
3 years ago
Read 2 more answers
Other questions:
  • People with healthy media diets:
    12·1 answer
  • Which is the last step in conducting a URL search?
    6·1 answer
  • The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create
    10·1 answer
  • Which of the following code is correct? I: print("Programming is fun") print("Python") print("Computer Science") II: print("Prog
    11·1 answer
  • You need to extract data from the system your predecessor created. you discover tables have been created according to the third
    7·1 answer
  • 27. If X and Y are int type variables,
    14·1 answer
  • (Count the occurrences of words in a text file) Rewrite Listing 21.9 to read the text from a text file. The text file is passed
    10·1 answer
  • What type of software is an antivirus?
    5·2 answers
  • A. Modify the FitnessTracker class that includes data fields for a fitness activity, the number of minutes spent participating,
    12·1 answer
  • A __________is a software program that appears to be a physical computer and executes programs as if it were a physical computer
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!