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
bazaltina [42]
4 years ago
5

Prompt the user for a string that contains two strings separated by a comma. (1 pt)Examples of strings that can be accepted:Jill

, AllenJill , AllenJill,AllenEx:Enter input string:Jill, Allen(2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)Ex:Enter input string:Jill AllenError: No comma in string.Enter input string: Jill, Allen(3) Using string splitting, extract the two words from the input string and then remove any spaces. Output the two words. (2 pts)Ex:Enter input string:Jill, AllenFirst word: JillSecond word: Allen(4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts)Ex:Enter input string:Jill, AllenFirst word: JillSecond word: AllenEnter input string:Golden , MonkeyFirst word: GoldenSecond word: MonkeyEnter input string:Washington,DCFirst word: WashingtonSecond word: DCEnter input string:
Computers and Technology
1 answer:
Veronika [31]4 years ago
7 0

Answer:

import java.util.Scanner;

public class ParseStrings {

public static void main(String[] args) {

/* Type your code here. */

Scanner sc= new Scanner(System.in);//to read inout from user

String sentence;//to hold user input

System.out.println("Enter input string");//asking user to input string reading into sentence

sentence=sc.nextLine();

while(!sentence.equals("q"))//continues untill user enters q

{

while(!sentence.contains(","))//loop ti eport error and continue till user enters valid string

{

System.out.println("No comma in string");

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

sentence=sc.nextLine();

}

//extracting words from senetnece

String word1=sentence.substring(0, sentence.indexOf(',')).trim();

String word2=sentence.substring(sentence.indexOf(',')+1).trim();

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

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

System.out.println("Enter input string");//asking user to input string reading into sentence

sentence=sc.nextLine();

}

 

return;

}

}

Explanation:

You might be interested in
What type of trust model is used as the basis for most digital certificates used on the internet?
vesna_86 [32]

The type of trust model that is used as the basis for most digital certificates used on the internet is known to be option B. distributed trust.

<h3>What is the trust model of the Internet?</h3>

The trust model of the internet is known to be one that is made up of tradeoffs.

Note that Distributed trust is seen as the system that is made up of transactions and it is one that is backed up by an extended community and onw where there is no trusted third parties.

Hence, The type of trust model that is used as the basis for most digital certificates used on the internet is known to be option B. distributed trust.

See full question below

What type of trust model is used as the basis for most digital certificates used on the Internet?

A. third-party trust

B. distributed trust

C. related trust

D. managed trust

Learn more about digital certificates from

brainly.com/question/24931496

#SPJ1

3 0
2 years ago
A(n) ____ is a client, server, or other device that can communicate over a network and is identified by a unique number, known a
Elden [556K]

Answer:

The answer is "node".

Explanation:

The network address is known as a logical or physical address, which defines a networking module/device from a network. It is an allocated numerical number, to every device requiring access to the list or is a member of it.

  • In network communication, it uses the nodes for store data, and there address, these addresses are described by the unique numbers.
  • These node stores data packets, which stores encrypted data.  
7 0
4 years ago
Any information that is processed by and sent out from a computer or other electronic device is considered __________.
wel

Answer:

Your answer will be output.

Hope this helps!

3 0
3 years ago
Read 2 more answers
What does VERONIcA stand for?
kompoz [17]
Very Easy Rodent-Oriented Netwide Index to Computerized Archives
5 0
4 years ago
Read 2 more answers
What steps can be used to open the Custom AutoFilter dialog box? Select any cell in the data range.
noname [10]

Answer:

Data

Sort and Filter

Text Filters

Explanation:

Proof that this answer is correct in the file attached.

6 0
3 years ago
Other questions:
  • Return to the Product Mix worksheet. Benicio wants to provide a visual way to compare the scenarios. Use the Scenario Manager as
    6·1 answer
  • Develop an sec (single error correction) code for a 16-bit data word. generate the code for the data word 0101000000111001. show
    6·2 answers
  • PLEASE HELP!!!! I'll mark Brainliest for whoever is first!!!!
    13·2 answers
  • Which document contains the dod cyber regulations for cui and cti??
    12·1 answer
  • By default, the Windows desktop displays
    6·1 answer
  • Which of these items will least likely increase pressure in the evaporative emission control system?
    9·1 answer
  • To move to the beginning of the line with the keyboard, press the _______ key(s).
    6·1 answer
  • A computer projecter is an example of a(n):<br> Input Device<br> Output Device<br> Storage Device
    12·2 answers
  • Before u can open and edit a file, you need to zip it, T/F
    12·1 answer
  • Given a sorted list of integers, output the middle integer. assume the number of integers is always odd.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!