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]
4 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]4 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
What is one benefit of using electronic flash cards?
velikii [3]

Answer:

They can be searched using keywords. they may have a different alarm settings. they provide a personal organizer.

Explanation:

Hope this helped Mark BRAINLIEST!!!

4 0
3 years ago
Read 2 more answers
What data unit is addressed based on the IP address of the recipient?
erica [24]

Answer:

packet

Explanation:

7 0
3 years ago
A series of inventions led to the creation of the electronic digital computer shortly after this war..
lesantik [10]
What is world war 2? bob
4 0
3 years ago
In the MARS Marketing Management Simulation, the results of your marketing mix decisions:
azamat
C- are only occasionally affected by the decisions made by other teams
explanation
idk
3 0
3 years ago
Nathan would like to save his PowerPoint presentation as a video that can be replayed easily on any device at full quality. Whic
aniked [119]

Answer:

Presentation Quality

Explanation:

7 0
3 years ago
Other questions:
  • What is the difference between a learner’s license and an operator’s license?
    13·1 answer
  • Bob received a message from Alice which she signed using a digital signature. Which key does Bob use to verify the signature?Gro
    13·1 answer
  • Which utility would you use to test communication on your own computer using your ip address as a parameter?
    10·1 answer
  • A network administrator wants to logically separate web servers on the network. Which of the following network device will need
    10·2 answers
  • Which of these components is a part of the Central Processing Unit (CPU) of a computer?
    11·2 answers
  • You can use colors, patterns, and borders to enhance the overall appearance of a worksheet and to make it easier to read. One of
    11·1 answer
  • Write a program named as reverse.c that reads a message, then prints the reversal of the message. The output of the program shou
    7·1 answer
  • B) What is system software? Write its importance.​
    13·1 answer
  • ____ is an example of a set of prewritten classes that allows you to access data stored in a database.
    8·1 answer
  • Select the skill that matches the following definition.​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!