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
What is the size of 5th generation of computer and what language does they use??​
kicyunya [14]

Answer:

The period of fifth generation is 1980-till date. In the fifth generation, VLSI technology became ULSI (Ultra Large Scale Integration) technology, resulting in the production of microprocessor chips having ten million electronic components

Fifth-generation languages are used mainly in artificial intelligence research. OPS5 and Mercury are examples of fifth-generation languages. as is ICAD, which was built upon Lisp. KL-ONE is an example of a related idea, a frame language

Explanation:

7 0
3 years ago
Read 2 more answers
____ is used specifically for the purpose of recording keystrokes, logging the programs or Web sites accessed, or otherwise moni
insens350 [35]

Answer:

Computer monitoring software

Explanation:

Computer monitoring software is used specifically for the purpose of recording keystrokes, logging the programs or Web sites accessed, or otherwise monitoring someone’s computer activity.

4 0
3 years ago
Read 2 more answers
Computer programs typically perform three steps: input is received, some process is performed on the input, and output is produc
-Dominant- [34]
True. Most basic programs follow this structure.
6 0
1 year ago
What is output if month = 11 and day = 14?
goldfiish [28.3K]

Cheese

…………………………..tggggggcfcgvgvv

4 0
3 years ago
Read 2 more answers
Need help ASAPppppppppp
Darina [25.2K]

Answer:

Below picture should give you an indication. On different PC cases, the position of the connectors can be different, so you have to look at the shape.

5 0
3 years ago
Other questions:
  • Trading your bicycle for a snowboard exemplifies ?
    15·1 answer
  • The efficiency of a screw is low because of _____. width friction length height
    10·2 answers
  • How do you access the dark web? What are the negatives of doing this?
    14·1 answer
  • Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
    13·1 answer
  • Which Windows feature allows secure printing over the Internet?​
    11·1 answer
  • It's about a truth table. No need to draw tables, 3 rows for the 3 columns is enough. Pls answer.
    10·1 answer
  • Where would you go to access frequently used icons?
    12·2 answers
  • And this also please. help​
    15·1 answer
  • PLEASE HELP WILLL GIVE BRAINLIESTTTTT!
    13·2 answers
  • Ryan is developing a camera app for iOS with the following objectives: make it easier for users to choose and sort pictures; and
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!