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
maria [59]
3 years ago
14

Write a program that uses a scanner to report some statistics about words in an input sentence ( see Section 7.8). The outputs s

hould be the number of words in the sentence, the average word length, and the length of the sentence.
Computers and Technology
1 answer:
Alla [95]3 years ago
8 0

import java.util.Scanner;

public class JavaApplication77 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter a sentence:");

       String sentence = scan.nextLine();

       String [] arr = new String[sentence.length()];

       arr = sentence.split(" ");

       System.out.println("There are "+arr.length+" words in the sentence.");

       int count = 0;

       for(int i = 0; i < arr.length; i++){

           count += arr[i].length();

       }

       System.out.println("The average length of a word in your sentence is "+(count/arr.length)+" characters");

       count = 0;

       System.out.println("Your sentence is "+sentence.length()+" characters long.");

       

   }

   

}

For the length of a sentence, I included spaces as characters but I did not do this for the length of a word. I hope this helps!

You might be interested in
Which of the following are addressed by programing design? Choose all that apply.
Viktor [21]

Answer:

Its B, D, and E

Explanation:

Hope this helps

6 0
3 years ago
Read 2 more answers
The frame work for storing records in database is a
andreev551 [17]
The frame work for storing records in database is a report. (b)
3 0
3 years ago
Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
Varvara68 [4.7K]

Answer:

Explanation:

Farmers are always both directly and indirectly connected to each other

Their network is mostly strong

Networks become weak only on the edges (ends) of the river but doesn't completely dimnish

With the available network length, the center of river bank forms the strongest network of all and becomes a key player in defining the balance property of overall network

The network is very well structurally balanced and we can see that through the below image

20 miles 10 20 30 40 50

See attachment file for diagram

Considering the total length of river as 50miles and and the center of the whole length will be at 25th mile. From that point, if we consider a farmer will be be having friends for a length of 20miles both along upstream and downstream.

By this he'll be in friend with people who are around 80% of the total population. As me move from this point the integrity increases and this results in a highly balanced structural network.

6 0
3 years ago
Whats 400000 time 93823
Fynjy0 [20]
Its 375,292,000,00





Yay.....
7 0
3 years ago
Read 2 more answers
Which explanation best explains the importance of using encryption?
andrezito [222]

Answer:

can you pls type the answer choices in the comments

5 0
2 years ago
Other questions:
  • What is the function of series-parallel circuit
    9·1 answer
  • Can you block someone on Brainly?
    7·2 answers
  • Charles is having a lot of problems with errors in a very complicated spreadsheet that he inherited from a colleague, and he tur
    8·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 the output is
    5·1 answer
  • Which of the following are examples of how a company might use consumer data it had collected? a To decide what types of product
    10·1 answer
  • Is techonalygy harmful or useful
    6·2 answers
  • Nielsen purchases scanner data from retail transactions to track the sales of consumer packaged goods, gathered at the point of
    14·1 answer
  • The function of network switch is to _____.
    5·1 answer
  • in a typical e-mail address, the "host" is A. an account designated by a user name B. CPU processor 2500 C. the receiver of an e
    12·2 answers
  • When writing an algorithm, the step after carrying out your plan is "sharing results."
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!