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
Which of the following words is an anatomy for cautious
liraira [26]
Uh, I think you mean antonym.

Anyways, here are some antonyms.

Careless, Certain, Foolish, Inattentive, Incautious
8 0
3 years ago
¿Por qué es importante que lo países crezcan a nivel tecnológico?
IrinaK [193]

Answer:

Importancia de la tecnología en el crecimiento económico de los países. ... El desarrollo de estas vías tecnológicas aporta un aspecto positivo como el ahorro del tiempo, la disminución de los esfuerzos de los trabajadores que permite una economía progresiva.

Explanation:

4 0
2 years ago
What is a characteristic ofa good cloud-based hosting?
Aliun [14]

Answer:

Explanation:

A good cloud-based hosting has many beneficial characteristics, some of which include on-demand self-service, broad network access, and being very elastic and scalable. These characteristics allow for a large number of users to benefit from the service at any time of the day and at a very fast speed due to the broad network access.

6 0
3 years ago
What will be the topic of the essay?
bonufazy [111]
Are actors and athletes paid too much?
8 0
3 years ago
Which statement is true for slide or positive film?
Hitman42 [59]

Answer:

B.

Slides or positive films give high quality pictures with higher color saturation and contrast.

Explanation:

The above is true for slides with positive film. This is because, the positive film happens to have a high resolution when it was been used thereby giving out a high quality video at the end of the recording. The higher colour saturation and contrast are also an attribute of a slide  or positive film.

6 0
2 years ago
Other questions:
  • ________ is the abbreviation for the place in the computer where the programs and data the computer is currently using are store
    8·1 answer
  • In the MOV instruction both operands i.e. source andthe destination cannot be
    15·2 answers
  • How to cite a website, like asha.org?
    6·1 answer
  • Egyptian hieroglyphs were part of a writing system used by the ancient Egyptians. What type of graphic design elements did they
    13·1 answer
  • Priscilla is providing the junior analysts in her firm with some real-world illustrations to explain some of the recommendations
    12·1 answer
  • An inventory clerk, using a computer terminal, views the following on screen: part number, part description, quantity on hand, q
    8·1 answer
  • Can anyone please help with this programming code in python num= 7 if num > 3: print(“3”) if num < 5: print(“5”) if num ==
    6·1 answer
  • A company accidentally sends a newsletter with a mistyped website address. The address points to a website that has been spoofed
    8·1 answer
  • Which operating system (OS) is used to run your laptop?
    15·2 answers
  • How to square a number in java.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!