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
Read the scenario and answer the question:
mel-nik [20]
C even the rest of answers seem practical c would be most likely
4 0
2 years ago
Read 2 more answers
An administrator has several cables plugged into a patch panel and needs to determine which one comes from a specific port. Whic
Pavel [41]

Answer:

Tone Generator and Probe

Explanation:

Tone generator is the device that generate a signal while probe is used to detect the signal. During the cables are connected to different port while establishing a system, it is required to check the cables that are connected to different ports.

With the help of tone generator, a signal has been sent through the cables that need to checked before connection. The signal are tested on the other end of the cable to determine the different types of cable that are connected to different ports.

So, the administrator should use tone generator and probe to determine that which cable is connected to which port.

7 0
3 years ago
Asymmetric encryption uses only 1 key.<br><br> A) <br> False<br><br> B) <br> True
motikmotik
A.) false

Symmetric encryption uses a single key that needs to be shared among the people who need to receive the message while asymmetric encryption uses a pair of public key and a private key to encrypt and decrypt messages when communicating.
5 0
3 years ago
Read 2 more answers
Write an application that counts by five from 5 through 500 inclusive, and that starts a new line after every multiple of 50 (50
MArishka [77]

Answer:

Replace the comment

//Write your code here

with

for(int i =5; i<=500;i++){

System.out.print(i+" ");

if(i%50 == 0){

System.out.println();

}

}

Explanation:

See attached for the full program

This line iterates from 5 to 500

for(int i =5; i<=500;i++){

This prints each digit

System.out.print(i+" ");

<em>The following if condition checks if current digit is a multiple of 5; if yes, a line is printed</em>

<em>if(i%50 == 0){</em>

<em>System.out.println();</em>

<em>}</em>

}

Download txt
5 0
3 years ago
The computer sums the first four digits of a customer number to calculate the value of the fifth digit and then compares that ca
Ainat [17]

Answer:

Answer to the following is check digit verification or validation.

Explanation:

The check digit is an important function of the validation or verification.

  • It ensures that the code which is produced by the computer system and re-entered into the another computer is correct or not.
  • It is an individual digit which are added at the end of the code by the computer system.
8 0
4 years ago
Other questions:
  • Supermarket managers who use scanners on the checkout counters to track inventory levels of their products are using a(n) ______
    11·1 answer
  • "where is a cookie that is created during a web site visit​ stored?"
    9·1 answer
  • You are creating a database for your computer club. Most of the students live in your town, Durham. How can you make Durham appe
    11·1 answer
  • Which storyboard component is a pictorial summary of how web pages in a website will connect with one another?
    12·1 answer
  • The Account class contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and a
    14·1 answer
  • I will mark you Brainliest if you could guess how old i am :3
    9·1 answer
  • Flash drive DVD and hard drive are all examples of
    6·2 answers
  • .
    5·1 answer
  • Differentiate between Computer Science and Information Technology
    10·1 answer
  • What year does futurist ray kurzweil believe ai will meet human intelligence?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!