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 the unit of measure ment to easure cpu speed
Hatshy [7]

Answer:

gigahertz (GHz )

Explanation:

A “cycle” is technically a pulse synchronized by an internal oscillator, but for our purposes, they're a basic unit that helps understand a CPU's speed

7 0
3 years ago
If the ____________ is broken on a laptop, chances are other parts are also broken.
ella [17]
Central processing Unit
8 0
3 years ago
If a*b = 2a - 56, calculate the value of<br>3 * 4​
tino4ka555 [31]

Answer:

A=34

Explanation:

Rewrite the equation as 2a−56=3⋅4

2a−56=3⋅4

Multiply 3 by 4

2a−56=12

Move all terms not containing a to the right side of the equation.

2a=68

Divide each term by 2

and simplify.

a=34

3 0
3 years ago
Which name is a default library name in Windows 7?
Blizzard [7]

Answer:

In Windows 7, there are four default libraries: Documents, Music, Pictures, and Videos. All the default libraries include two standard folders: the user folder specific to each library and the public folder specific to it.

Explanation:

6 0
3 years ago
Wireless technology is best described as a/an
IgorLugansk [536]

Answer:

mobile computing system

Explanation:

6 0
4 years ago
Read 2 more answers
Other questions:
  • Why should you avoid the use of sarcasm cliches and idioms in busniess letters?
    9·2 answers
  • Connie decided that her paper should be organized in the order in which the events happened. What type of organizational method
    15·1 answer
  • To what does the term computer hacking refer?
    10·2 answers
  • A_______is a limitation imposed on the engineer. It can be a limitation on
    5·1 answer
  • Which of the four digital-to-analog conversion techniques is the most susceptible to noise? EXPLAIN WHY.
    6·1 answer
  • Which firewall monitors traffic from the DMZ to the LAN?
    11·1 answer
  • In the movie, Willy Wonka and the Chocolate Factory, Augustus Gloop leans over the chocolate river to get a drink and falls in.
    11·1 answer
  • What do commercial websites use to estimate a visitor's age, gender, and zip code?
    10·1 answer
  • What is the minimum amount of hard drive space required for a 64-bit Windows 10 installation?
    7·1 answer
  • what new technology led to the chaos that spurred the establishment of the federal communications commission?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!