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]
2 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]2 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
Given the following function definition, what modifications need to be made to the search function so that it finds all occurren
svet-max [94.6K]

Answer:

D. have function return the whole array

Explanation:

the given function only return first occurrence of target. In order to get all occurrences of target we have to change condition in while loop to check whole array even if first occurrence of target found and plus add another parameter of type array that will store different  indexes of occurrence of target and return that array

8 0
3 years ago
The domain in an email message tells you the
Vsevolod [243]
<span>The domain in an email message tells you the location of the destination.  A domain is a part of an e-mail address after @. Let us say, [email protected], aol.com is the domain. Therefore, the answer is letter B. location of the destination, and as for the case of the given example above, aol.com is called the location of the destination.

Other examples of domain that we commonly came across with:
[email protected] gmail.com
[email protected] yahoo.com
[email protected] msn.com

</span>


6 0
3 years ago
Read 2 more answers
• What is the difference between primary storage, secondary storage, and off-line storage
sergiy2304 [10]


Primary storage refers to your RAM it is internal storage.

Secondary storage is any storage that is not the primary storage that permanently stores data. Examples are hard drive, tape disk drive, floppy disk drive  and compact disk drive. 

Off-line storage refers to any device that stores data that is not permanently attached to the computer. Example flash drives, The data remains on the storage device and can be connected to a different computer. 

3 0
3 years ago
How many responses does a computer expect to receive when it broadcasts an ARP request?why?
Alla [95]

Answer: The response that is expected when it broadcast an ARP request is one or zero.

Explanation: ARP request means Address Resolution Protocol which is a protocol responsible for the mapping of the IP(Internet protocol)address of a system to the MAC(Media Access Control) layer. Only one response is received only if the IP address is present in the ARP otherwise if the IP address does not matches then no response is returned.Thus only one or zero response can be received when a ARP request is process.

5 0
2 years ago
What is the decimal value for the jump control?
Scorpion4ik [409]

Answer:

Is there suppose to be a pic?

Explanation:

7 0
2 years ago
Other questions:
  • _______________ ________________ have human editors that evaluate, select, and organize websites into a hierarchy of categories.
    11·1 answer
  • When hacking a website to test a secure connection and ensure internet safety, what is a good way to check the coding of the web
    14·1 answer
  • A ____________ is a collection of commands given a name.
    11·1 answer
  • When looking at security standard and compliance, which three (3) are characteristics of best practices, baselines and framework
    8·1 answer
  • MR. Tom asked her students could they plant a flower and bring it to class. Sarah brought his flower and said it was a rose. Jam
    6·1 answer
  • Why does it keep saying this when I’m putting my right credit card number
    6·1 answer
  • 1.<br>is the office industry leader at the moment.​
    9·1 answer
  • (a) What is the meaning of word 'computer (b) Cive a reason for the evolution of computer (c) Write a weakness of a computer (d)
    14·1 answer
  • Identify and explain 4 traditional (old ways) marketing approaches used by University uses in reaching
    7·1 answer
  • Do anyone know how to code like I need someone do a code for me?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!