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
Modern processors today utilize _____ when fetching instructions as a means of predicting where the branch will go and even begi
ss7ja [257]

Answer:Speculative prediction

Explanation: Speculative prediction is the prediction method which can be optimizing in nature.This method usually runs in such a way that can lead ahead of time by predicting the next step or it's result.

This technique is also known as the dynamic execution which is usually found in the CPU devices and some other modern processing devices.Speculation prediction and execution works even when there is no necessity of the knowing about the next instruction.The result appearing can be correct or incorrect.

3 0
3 years ago
What is also known as a visual aid in a presentation?
kap26 [50]

Answer:

Option D i.e., slide are the correct option.

Explanation:

The following option is true because in the PowerPoint presentation slide is the visual aid. With the help of the visual aid, the user can add the acumen to its PowerPoint presentation and it is the item in which the user can summarize their information and data that is slide. It is important for the creation of the official or the business purpose presentation.

3 0
4 years ago
Read 2 more answers
Consider the following incomplete code segment, which is intended to increase the value of each digit in a String by one. For ex
arlik [135]

The instruction that should replace /* Missing Loop Header */ so that the code segment works as intended is (c)  counter < num.length()

<h3>Loops</h3>

The program is an illustration of loops (the while loop)

While loops are program statements that are used to perform repeated operations

For the string to return 23456, the while loop body must be repeated as long the counter is less than the length of the string num

Hence, the missing loop header is counter < num.length()

Read more about loops at:

brainly.com/question/15683939

7 0
3 years ago
Wireless networks usually use ____ signals to send data.
barxatty [35]
<span>Wireless networks usually use radio (b) signals to send data. </span>
6 0
3 years ago
Read 2 more answers
What is the decimal form of the following binary ip address? 11001101.00111001.10101001.01000010
jasenka [17]

The decimal form of the 11001101.00111001.10101001.01000010 binary ip address is 205.57.169.66.

An IP address is a binary number with 32 bits. The 32 bits are divided into four octets, which are groupings of 8 bits each. An IP address, however, is shown as a dotted decimal number (for example: 205.57. 32.9).

Memory regions are given binary addresses by the computer system. But in order to access a memory location, the system utilises a certain number of bits. We can address two memory regions with 1 bit. We can address 4 memory locations with 2 bits and 8 memory locations with 3 bits.

The 4 sets of 8 bits in each of the 4 directions are simply written down to create the 32-bit binary IP address.

Learn more about binary ip address:

brainly.com/question/14541891

#SPJ4

3 0
2 years ago
Other questions:
  • Give the 16-bit 2's complement form of the following 8-bit 2's complement numbers: (a) OX94 (b) OXFF (c) OX23 (d) OXBCWhich of t
    7·1 answer
  • (The Location class) Design a class named Location for locating a maximal value and its location in a two-dimensional array. The
    10·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • What frequency band or bands do 802.11g, 802.11a, 802.11n, and 802.11ac use?
    13·1 answer
  • A Variable can only hold numbers<br><br> True<br><br> False
    15·2 answers
  • Please help! In your own words explain the difference between a problem and an algorithm.
    13·2 answers
  • Write a function template that accepts an argument and returns its absolute value. The absolute value of a number is its value w
    11·1 answer
  • c) If you are at foreign country visit, which banking card would you prefer to keep with you during visit (Debit Card or Credit
    10·1 answer
  • Inputs and outputs that allow a user to interact<br> with a piece of software
    14·2 answers
  • Which of the following safety and privacy features is not included in a P2P app or service?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!