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 questions do they ask for the 08.03 Discussion- Based Assesment in Drivers Ed?? Thanks.
mel-nik [20]

When should my headlights be turned on?

Why shouldn't one take medication before driving?

Why must you use a turn signal?

I'm not sure about that last one because I forgot but I think its right.

6 0
3 years ago
Name five different windows password policies.
rodikova [14]

The five different windows password policies are:

1. Enforce password history.

2. Minimum password length.

3. Minimum password age.

4. Maximum password age.

5. Password must meet complexity requirements. (contain symbols, numbers, letters,...) 

6 0
3 years ago
Which of the following technologies allows you to decouple the physical storage hardware from the storage requirements of the ap
bearhunter [10]

Answer:

Software Defined Storage

Explanation:

According to my research on different technological advancements, I can say that based on the information provided within the question the technology being described is called Software Defined Storage. This is a computer program that storage resources and functionality without depending on the hardware's physical storage capabilities.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
The _____ is an information and communication-based electronic exchange environment mostly occupied by sophisticated computer an
Temka [501]

Answer:

Marketspace

Explanation:

The question has already been answered (by you).

From this point, I'll give a brief description of the concept of marketspace.

In marketing, market space refers to a virtual market space and it is still a new concept in marketing; it emerged in mid 1990s.

It refers to a kind of electronic information exchange environment where the presence of physical interaction is completely removed i.e. no physical contact between the seller and the buyer.

So, A market space is an bringing together of several market places through technology but their presence are felt virtually.

5 0
3 years ago
Read 2 more answers
Helpppppppppppppphuhuh
Serga [27]

Answer:

B

Explanation:

You listed this as Computers and Technology where we post coding questions, or hardware related things, but ok.

If there is 7/8 jugs as the starting amount, and they have a 1/2 jug, dividing 0.875 by 0.5 gives the answer of 1.75 or 1 3/4.

3 0
2 years ago
Other questions:
  • 1. Data in a smart card can be erased
    6·2 answers
  • A poker hand consists of 5 cards drawn at random without replacement from a 52 card deck. Using python and the cards data frame
    12·1 answer
  • MTTF is a file format developed by Microsoft commonly used on Windows systems; it offers file security, large volume size, large
    11·1 answer
  • _____ allow you to logically separate ports in switches to create subdomains without wiring your network as physical subdomains.
    7·1 answer
  • Use the laws of propositional logic to prove the following:
    5·1 answer
  • Which of the following is the most effective password?
    6·2 answers
  • 5.8.1: Modify an array parameter. Write a function SwapArrayEnds() that swaps the first and last elements of the function's arra
    14·1 answer
  • "in troubleshooting a boot problem, what is the advantage of restoring all uefi/bios settings to their default values?"
    13·1 answer
  • Can you give me a long list of kid's cartoons
    11·2 answers
  • Which one is the right code
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!