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]
3 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]3 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 function returns a line and moves the file pointer to the next line?
Aneli [31]
The goto command

for example


:start

title ""graphing calculator""

goto start
5 0
2 years ago
What component of a change management program includes final testing that the software functions properly
ValentinkaMS [17]

A component of a change management program which includes final testing that the software functions properly is: C) Release management.

<h3>What is SDLC?</h3>

SDLC is an acronym for software development life cycle and it can be defined as a strategic methodology that defines the key steps, phases, or stages for the design, development and implementation of high quality software programs (applications).

In Computer science, there are seven (7) phases involved in the development of a software program and these include the following;

  • Planning
  • Analysis
  • Design
  • Development (coding)
  • Testing
  • Deployment
  • Maintenance

At the final testing stage, a component of a change management program which ensure that the software functions properly is known as release management.

Read more on software here: brainly.com/question/26324021

#SPJ1

Complete Question:

What component of a change management program includes final testing that the software functions properly?

A) Request management

B) Change management

C) Release management

D) Iteration management

5 0
1 year ago
. Hackers generally disguise their IP address. True False
maw [93]
I think that's true.
If they didn't they could be easily tracked by the police.
4 0
3 years ago
write a simple assembly code using 8088 microprocessor instruction set to add two numbers ? please help me if you know :(​
Kay [80]

Answer:

sexxxxx chaaaaat insta id abhilash0351

3 0
3 years ago
What is the difference between posting and transfer in ICT please I need the answer before TMR​
Radda [10]

Answer: b

Explanation: trust

7 0
2 years ago
Other questions:
  • 12. Good digital citizenship includes keeping in mind who has access to the internet and who does not. (1 point)
    15·2 answers
  • _______ refers to the poitically, religiously, or ideologically motivated use of computers (or related technology) by an individ
    15·1 answer
  • What does the Additional Clock tab do?
    11·1 answer
  • A mother calls you to report that her 15-year-old daughter has run away from home. She has access to her daughter's e-mail accou
    6·2 answers
  • COMPUTER SCIENCE:PIXELS
    5·1 answer
  • You have a web application hosted in AWS cloud where the application logs are sent to Amazon CloudWatch. Lately, the web applica
    7·1 answer
  • Who is hurt by piracy
    10·1 answer
  • Application of computer in insurance​
    14·1 answer
  • For all programs, you should write a small amount of code and _______
    6·1 answer
  • Five uses of the operating system​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!