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
Give an example of a process that may need a flowchart to clarify procedures.<br><br> HELP ASAP!
11111nata11111 [884]

To understand flow of programming logic flow chat technique been used. Once end user starts any learning programming flow chat design been learned and corrected the mistake. After success of flow chat design end user been advice to do programming and tested in computer.

<u>Explanation:</u>

In flow chart design is used for beginner level programming. Some time to make higher level managers to understand this flow chart design is used.

Flow chart has start, procedure, condition, function or procedure and end with stop diagrams.

Flow chart makes end user understand the flow of logics.

Suppose we need to do a process for a procedure, end user has to design with start flow chart symbol and put a procedure flow chart symbol with identification character, then end user has use same identification character and start designing the procedure in the flow chart diagram.

Procedure in flow char design is used to call same procedure number of time, so that repeated coding is avoided.

5 0
3 years ago
• R7.9 Write enhanced for loops for the following tasks.
alexdok [17]

Answer:

a is the correct answer

Explanation:

correct me if I'm wrong hope it's help thanks

3 0
2 years ago
Why do amusement parks continue to build new roller coasters?
kykrilka [37]
They do it because they want people to experience new rides, instead of the same old boring rides they’ve been on several times.
5 0
3 years ago
Read 2 more answers
Given a sorted list of integers, output the middle integer. assume the number of integers is always odd.
Svetllana [295]

integer userInput

integer i

integer mid

integer array(20) number

userInput = 1

for i = 0; userInput >= 0; i = i + 1

  if number[i] > -1

     userInput = Get next input

     number[i] = userInput

i = i - 1

mid = i / 2

if i > 9

  Put "Too many inputs" to output

elseif i % 2 == 0

  Put number[mid - 1] to output

else

  Put number[mid] to output

4 0
2 years ago
What is meant by algorithm?​
ExtremeBDS [4]

Answer:

a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.

Explanation:

7 0
3 years ago
Other questions:
  • While designing web pages for mobiles, the page content should be extensive such that the readers get the opportunity to explore
    5·2 answers
  • Cuales Son las características de la máquina analítica de Carlos Babbage ?
    11·1 answer
  • What are some ways tables can be inserted into a document? Check all that apply.
    5·2 answers
  • Our Client, a renowned trading company, suffered a sudden, devastating power outage that caused their server to cease functionin
    13·1 answer
  • TRUE OR FALSE: THE BUILDER'S CLUB IS A PAID SUBSCRIPTION.
    9·2 answers
  • Example of Bandwidth Analogies: using Pipe
    11·2 answers
  • 1. This tab displays the related commands which are grouped as Pages, Tables, Illustrations, Links, Header and Footer, Text, Sym
    13·1 answer
  • What happens when you create a variable in a video game program?​
    5·1 answer
  • Which one did I buy the iPhone 13 or the Samsung S22 Ultra?
    14·2 answers
  • Consumers affect which goods and services are produced because they _____.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!