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
Gnesinka [82]
3 years ago
5

Write a program that reads in text from standard input (hint: use Scanner) and prints out the number of words in the text. For t

he purpose of this exercise, a word is a sequence of non-whitespace characters that is surrounded by whitespace.
Computers and Technology
1 answer:
Vitek1552 [10]3 years ago
4 0

Answer:

The solution code is written in Java

  1.        Scanner input = new Scanner(System.in);
  2.        System.out.print("Enter a text: ");
  3.        String inputStr = input.nextLine();
  4.        String wordList[] = inputStr.split(" ");
  5.        System.out.println("The number of word in the input text: " + wordList.length);

Explanation:

Firstly, create a Scanner object to read the user input text using nextLine method (Line 1-3).

Next, we can use the string split method and use single space " " as the separator to convert the input text to an array of individual word (Line 5).

We can simply use println to display the number of words in the array by using the length property of the array (Line 7). The word count is equal to the array length.  

You might be interested in
You have been given the following String which represents a series of 6 side die rolls:rolls = "1,5,2,3,5,4,4,3,1,1,1,2,3,1,5,6,
Anni [7]

Answer:

see explaination

Explanation:

rolls="1,5,2,3,5,4,4,3,1,1,1,2,3,1,5,6,2"

list1 = list(rolls.split(","))

print("The total # of rolls: {}".format(len(list1)))

j=0

for i in list1:

j+=int(i)

print("Total value of all rolls: {}".format(j))

print("Average roll: {}".format(j/len(list1)))

Please kindly check attachment for program code and output

8 0
3 years ago
Does anybody know a better app I can use instead of Brainly
melomori [17]

Answer:

Education subreddits on reddit

Explanation:

6 0
3 years ago
Read 2 more answers
If you had three extra siblings, what would be your birth order and what personalities would you like them to have?
Annette [7]

Answer:

mixed personalities l

that will be cool

3 0
3 years ago
Read 2 more answers
If a driver who is under the age of 21 is stopped by a law enforcement officer and shown to have a BAL of .02 or greater, he or
n200080 [17]
Its actually BAC (clood Alchohol Content) and  it dependsn on what state you live in, and usually first time offenders with a BAC over 0.15 will have their license suspended for 90 days. but again it depends on the state. and anything below a 0.08% will just result in a warning but what state is it?
5 0
3 years ago
Which of the following is true about speculative risks? a. The risk/return tradeoff is applicable to speculative risks. b. Specu
My name is Ann [436]

Answer:

A) The risk/return Tradeoff is applicable to speculative risks.

Explanation:

Speculative risk always has a positive payoff and also a negative payoff , so option (b) is incorrect.

Speculative risk is a source of great concern for risk managers, so option (c)is incorrect.

Speculative risk is a category of risk that can be taken on voluntarily and will either result in a profit or loss , so option d is wrong

Pure risk, also called absolute risk, is a category of threat that is beyond human control and has only one possible outcome if it occurs: loss. Pure risk includes such incidents as natural disasters, fire or untimely death. so option (e) also incorrect

7 0
2 years ago
Other questions:
  • What do TCP/IP MEAN​
    7·1 answer
  • What is required when opening a checking account?
    14·2 answers
  • What is wrong with line 1?
    14·1 answer
  • The optional feature in a business letter is
    10·1 answer
  • Write a function named replaceSubstring. The function should accept three C-string arguments, let's call them string1, string2,
    8·2 answers
  • "Save" or "save as" can be used interchangeably and have no unique features.<br> True<br> False
    12·2 answers
  • G The method of mapping where each memory locationis mapped to exactly one location in the cache is
    9·1 answer
  • Which option should Gina click to edit the text contained in a text box on a slide in her presentation?
    10·1 answer
  • Password ____ traverse the network searching for passwords from remote authentication systems.
    6·1 answer
  • Which website offers guidance on putting together a checklist to provide guidance on configuring and hardening operating systems
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!