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
Visual basis,C, C++ and Java are all examples of computer programming ________.
mafiozo [28]
Programming languages im pretty sure
4 0
3 years ago
Which devices are managed through device management?
Ratling [72]
Answer:
computers and Mobile phones ( including game consoles and tablets) are managed through device management
Explanation:
Device management includes a type of security software used to monitor,secure and manage systems such as mobile phones computer laptops and desktops, Tablets and smart televisions as well as Game consoles. It as well involves the management,operation and maintenance of the physical aspect of the systems from external threats/intruders
Anti virus software is an example of a device management software used to protect systems from malware, by detecting and removing them and also by preventing them.
Firewall is a complete device management tool because it detects and prevents intruders and virus from penetrating the system software
7 0
2 years ago
Que es un algoritmo informático?
nasty-shy [4]

Answer:

An algorithm is a specific procedure for solving a well-defined computational problem. ... It requires an understanding of the alternatives available for solving a computational problem, including the hardware, networking, programming language, and performance constraints that accompany any particular solution.

4 0
2 years ago
Read 2 more answers
Tom has just started working as an intern for a local radio station. He is responsible for managing the request line and present
const2013 [10]

Answer:

Live Preview.

Explanation:

This is a feature specifically found in the microsoft power point in detailing or slides showing in a preliminary stage of its previews.

By default, when you select the composing email content and change its text format, such as text font, size, color and so on, the live preview will be displayed when you put your cursor on different text format.

Actually the live preview function can be enabled or disabled manually in Outlook. In this tutorial, we will show you how to enable or disable live preview in Outlook in details.

7 0
3 years ago
Please answer........
Vitek1552 [10]

Using the try-except statement, the fix is as follows:

while True:

   try:

       boxes = int(input("How many boxes do you have?"))

       sweaters = int(input("How many sweaters do you have?"))

       break

   except:

       print("Input invalid")

sweatersPerBox = sweaters/boxes

print("You need to put",sweatersPerBox,"sweaters in each box")

<h3>How to prevent the program from crashing?</h3>

The program is given as:

boxes = int(input("How many boxes do you have?"))

sweaters = int(input("How many sweaters do you have?"))

sweatersPerBox = sweaters/boxes

print("You need to put",sweatersPerBox,"sweaters in each box")

The above program would crash when the user enters string inputs.

Examples of string inputs are "7h", "bh"...

One way to fix the error is the use of the try-except statement.

Using the try-except statement, the fix is as follows:

while True:

   try:

       boxes = int(input("How many boxes do you have?"))

       sweaters = int(input("How many sweaters do you have?"))

       break

   except:

       print("Input invalid")

sweatersPerBox = sweaters/boxes

print("You need to put",sweatersPerBox,"sweaters in each box")

The above program would continue running until the user enters a valid input

Another way is to end the program when the user enters string inputs

Read more about python programs at:

brainly.com/question/26497128

#SPJ1

7 0
2 years ago
Other questions:
  • NEED HELP(10 POINTS) PLEASE HELP MATH
    8·2 answers
  • Which of the following statements about take home pay is TRUE?
    10·1 answer
  • Write a C++ program that determines if a given string is a palindrome. A palindrome is a word or phrase that reads the same back
    6·1 answer
  • What process combines data from a list with the content of a document to provide personalized documents?
    9·2 answers
  • Computer design replaced ______________
    14·1 answer
  • You are sending an email to a coworker requesting that the coworker perform a task. Where should you put your coworker's email a
    8·1 answer
  • This whole page needs to be done please help?
    13·1 answer
  • In C complete the following:
    12·1 answer
  • The command to get out of the loop.<br>a.<br>i exit<br>ii. break<br>iii. comment<br>iv. for​
    12·1 answer
  • You should always be afraid to use the internet<br><br> True or false?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!