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
Andrew’s Complete Cameras offers its customers an interactive website to help them choose the best camera for their lifestyle. B
anzhelika [568]

Answer:

The answer to the following question is Engage.

Explanation:

4e framework is the new framework for the marketing communications with the social media.

EXCITE the customers with the relevant offer.

EDUCATE the customers about the offerings.

Help the consumers EXPERIENCE for the product, indirectly or directly.

ENGAGE with them on the common platform.

7 0
3 years ago
Coding with Loops Worksheet
BartSMP [9]

Answer:

if you give me brainliest i will answer your question

Explan

4 0
3 years ago
Read 2 more answers
The ________ simulates your work area.
xz_007 [3.2K]
I believe it is, A. taskbar
5 0
3 years ago
Don't click on this I am testing
Andrew [12]

Don't click on this I am testing... I want the points so.

3 0
3 years ago
Read 2 more answers
When one citizen has access to digital resources and the other does not, the opportunity gap existing between them is called the
allsm [11]
The digital divide :)
5 0
3 years ago
Other questions:
  • What is a nonlinear presentation
    9·2 answers
  • Constantine forms the following hypothesis. Let n be any non-negative number that meets the following condition: when n is divid
    10·1 answer
  • А.<br> is the highest education degree available at a community college.
    6·1 answer
  • What will happen when a user attempts to login to salesforce from an ip address that is outside the login ip range on the user's
    15·1 answer
  • What does social protocol means in network?
    9·1 answer
  • Why is there no ide length or timing for study breaks?​
    12·1 answer
  • A customer seeks to buy a new computer for private use at home. The customer primarily needs the computer to use the Microsoft P
    9·1 answer
  • Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correc
    9·2 answers
  • PHOTOSHOP IS A GRAPHICS EDITING PROGRAM CREATED WITH IMAGES KNOWN AS________ ​
    6·1 answer
  • Write a program that asks the user to enter a positive integer that represents a number in the decimal system and then displays
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!