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
What is the value of 8n when n= = 2?​
lidiya [134]

Answer:

The value of 8n would be 16

8n

8(2)= 16

(uhh this is a math question right? Sorry if it has to deal with tech)

6 0
3 years ago
In the context of web and network privacy issues, new employees in an organization have to sign a(n)__________ before they acces
Lunna [17]
In the context of web and network privacy issues, new employees in an organization have to sign an acceptable use policy (AUP) before they access the network. This usage policy<span> or fair use policy, </span> provides guidance and set of rules for using the network and network resources and protects the network and the users. 
3 0
3 years ago
Read 2 more answers
From which Menu option you can change page setup in MS Word​
marissa [1.9K]

page layout tab or the page setup dialog box

8 0
2 years ago
Peter works on a huge database of numerical figures in a worksheet ranging from cell A1 to cell I50. He has to print the workshe
bekas [8.4K]

Answer:

Landscape or vertical page orientation

Explanation:

In landscape  he can mange the number of cell that are required to print on A4 page size.

On landscape orientation of the page we can add more columns of the sheet. That is the reason, we should choose landscape or horizontal page orientation to adjust all columns on the single page.

8 0
3 years ago
Read 2 more answers
Input is information a system uses to monitor and adjust itself to meet the goal.
agasfer [191]
That is a true statement. Hope this was helpful!
7 0
3 years ago
Other questions:
  • A hacker changing the ip addresses used in conjunction with a particular company’s web site to re-route them to the hacker’s ser
    11·1 answer
  • Frank has created a résumé and separated the sections using headings. How can he set the headings apart from normal text?
    13·1 answer
  • What cell phone technology is the most popular in the united states?
    8·2 answers
  • Person-name: String+setName(String name): void+getName(): String^Student-studentID: long+Student(String sname, long sid)+setID()
    10·1 answer
  • If you are logged on to Windows Live Messenger, why would you be unable to engage
    6·1 answer
  • Why is population composition by age important give reason​
    13·1 answer
  • How is the OR (||) logical operator used?<br> PLS HURRY
    11·1 answer
  • Which of the following tools helps ensure your document will open in older versions of word
    13·1 answer
  • Another name of computer program is
    6·1 answer
  • What are the benefits and drawbacks of a desktop utilising virtualisation and a server?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!