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
Kahoot plzkahoot plzkahoot plz
Evgen [1.6K]

MAKE ONE AND SEND THE CODE !! I'M SO BORED RN IT ISN'T NORMAL HAHAHAHA

4 0
3 years ago
How can I master the computer organization ​
inn [45]

Answer:

This course qualitatively and quantitatively examines computer design trade-offs, teaches the fundamentals of computer architecture and organization, including CPU, memory, registers, arithmetic unit, control unit, and input/output components.

Explanation:

it can be difficult. For me it was one of the most challenging classes but also one of the my most interesting ones. You gain an understanding of what occurs at 7 different layers of abstraction (similar in theory to the OSI model used in networking but different). It can be hard

7 0
2 years ago
The role of the
ElenaW [278]

Answer:

Tcp

Explanation:

8 0
3 years ago
Which material, distributed to audience members, contains additional information about topics covered in the presentation?
Vladimir79 [104]
Outlines because you would not want the audience to know what exactly is on the slides, but just an outline to give them an idea of what is to come.
8 0
3 years ago
Read 2 more answers
Although the chi-square distribution is continuous, it is used to analyze discrete (counts) data
Roman55 [17]
This is true! The chi-square distribution is continuous and it is used to analyze discrete (counts) data.
4 0
4 years ago
Other questions:
  • What symbol following a menu command lets you know that a dialog box will be displayed?
    14·1 answer
  • A School is interested in computerizing their students<br />grading system.<br />I Marks Grade<br />150-100 A&
    11·1 answer
  • Please check my answer! (Java)
    8·1 answer
  • Write a compound inequality that is represented by the graph.
    14·1 answer
  • What is computer networking?
    14·1 answer
  • What is the purpose of indexing?
    15·2 answers
  • Which tools is used to bundle cables neatly inside and outside of a computer?​
    15·1 answer
  • I've been stuck on these two basic javascript assignments for an embarrassingly long time. The teacher refuses to help me and th
    13·1 answer
  • Parameters and return make
    10·1 answer
  • The short-range two-way communication technology behind contactless payments is called ____.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!