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
What unit is used to describe the smallest amount of bitcoin?
diamong [38]

Answer:

The satoshi is currently the smallest unit of the bitcoin currency recorded on the block chain. It is a one hundred millionth of a single bitcoin (0.00000001 BTC).

Explanation:

A bitcoin is a type of digital currency in which a record of transactions is kept and new units of currency are generated by the computational solution of mathematical problems. Bitcoins operate independently through a central bank.

7 0
3 years ago
Critical Thinking Questions
nydimaria [60]
You’re profile is so cute hope this helps :)
5 0
2 years ago
Which structures protect the cell? Select two options.
Rzqust [24]

Answer:

cell wall

cell membrane

3 0
1 year ago
What section in an ethernet frame will you find a Virtual Local Area Network (VLAN) header?
Vadim26 [7]

Answer:

Preamble

Explanation:

In the computer network , the ether-net is the frame of link layer protocol data. This frame is used ether net with physical layer of transport mechanism. The ether net frame is of different type.

  • The ether-net II
  • The Novel raw IEEE 802.3
  • IEEE 802.2 LLC
  • IEEE 802.2 SNAP

Each of the Ethernet frame started from Ether net header. It contains the source and the destination. The MAC address is called its first two address.

8 0
3 years ago
Which of the following cools the air in a household refrigerator?
Ivanshal [37]

The following cools the air in a household refrigerator: Absorption of the heat from the air due to evaporation of the liquid refrigerant . Correct answer:B

The function of the refrigerator is to absorb heat into the refrigeration system. The evaporator is placed in the area to be cooled. The refrigerant vaporizes from the heat it absorbs heat in the evaporator.

4 0
2 years ago
Read 2 more answers
Other questions:
  • Consider the pseudo-cpu discussed in class. the instruction format is 16 bits, which is subdivided into 4-bit opcode field and 1
    14·1 answer
  • Direct messaging is similar to email, except
    5·2 answers
  • If necessary, create a new project named Advanced19 Project, and save it in the Cpp8\Chap06 folder. Enter (or copy) the instruct
    15·1 answer
  • I am having trouble figuring out if this is correct. Can someone please help me ASAP?
    10·1 answer
  • The function known as "Comments" can be displayed during a presentation<br>O True<br>False​
    5·2 answers
  • You have added a table to your web page consisting of two columns and five rows, including the header row. in the first header c
    13·1 answer
  • Discuss five processes for analyzing a qualitative study
    11·2 answers
  • Tier 1 networks form the internet ____.​
    15·1 answer
  • What are four differences between tablets and smartphones?
    6·2 answers
  • Which tools can help you gather information about the processes running on a windows operating system?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!