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
V125BC [204]
3 years ago
10

Write a Java program to count the characters in each word in a given sentence?Examples:Input : geeks for geeksOutput :geeks->

5for->3geeks->5
Computers and Technology
1 answer:
dimulka [17.4K]3 years ago
4 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

   

    Scanner in = new Scanner(System.in);

   

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

    String sentence = in.nextLine();

   

    String[] words = sentence.split("\\s");

   

    for(String s : words)

     System.out.println(s + " -> " + s.length());

}

}

Explanation:

Ask the user to enter a sentence

Get each word in the sentence using split method and put them in words array

Loop through the words. Print each word and number of characters they have  using the length method in required format

You might be interested in
Pls help :( I am a radio and audio production student. What are two examples of a complex wave?
Brilliant_brown [7]

Answer:

A complex wave is a wave made up of a series of sine waves; it is therefore more complex than a single pure sine wave. This series of sine waves always contains a wave called the "FUNDAMENTAL", that has the same FREQUENCY (repetition rate) as the COMPLEX WAVE being created.

Examples for complex wave:

<em>• The Square wave </em>

<em>• The Triangular wave </em>

<em>• The Saw-tooth wave</em>

<em />

<em>Hope you got it </em>

<em> If you have any question just ask me </em>

<em>If you think this is the best answer please mark me as brainliest</em>

4 0
3 years ago
______ devices are high-performance storage servers that are individually connected to a network to provide storage for the comp
natali 33 [55]
NAS - network attached storage
3 0
3 years ago
What is &lt;html&gt;
ipn [44]

the opening tag for an HTML document

8 0
3 years ago
Read 2 more answers
In Criminal justice, the type of evidence which contradicts a given theory is known as?​
irina [24]

Answer:

In general, scientific evidence are the results of scientific tests used to prove or disprove a theory or hypothesis. In criminal cases, scientific evidence is used to help jurors understand and determine the facts of a case. Explanation:

3 0
3 years ago
The shapes of AND, OR, and NOR gates have something in common. What is it and why do you think they share that feature?
irina1246 [14]
There're all conjunctions.

You can seperate them in sentences after a comma for a run-on sentence.
4 0
3 years ago
Other questions:
  • The type of database that uses fields, records, and measure as data attributes is
    7·1 answer
  • In each iteration, selection sort (small) places which element in the correct location?
    9·1 answer
  • Assuming you have a TCF free student checking account, how many maximum overdraft fees can you incur in one day?
    12·1 answer
  • __________ is a protocol used by e-mail clients to download e-mails to your computer.
    14·1 answer
  • Describe at least three virus scanning techniques
    13·1 answer
  • "If a user on a laptop complains that they are unable to sign into Windows even though they are certain they are entering the co
    12·1 answer
  • What output is generated by this for loop?
    6·1 answer
  • What do you hope will be in/added GTA 6?
    13·1 answer
  • I want the answer of this task ( using prolog language ) ASAP because the deadline is tomorrow. Please help :"
    15·1 answer
  • Cable inside the computer transferring data between the mother board and storage devices.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!