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
According to the video, which of the following is communication between two individuals? Intrapersonal Communication Public Spea
DedPeter [7]

Answer:

The Last option: Dyadic Communication AND Interpersonal Communication

is the correct one.

Explanation:

Communication can be defined as the process in which one may convey his thoughts or inquires about things.

There are many types of communications as listed above.

  • Intrapersonal Communication
  • Interpersonal Communication
  • Dyadic Communication
  • Small Group Communication
  • Public Communication
  • Mass Communication
  • Organizational Communication
  • Intercultural Communication.

Under all these, Interpersonal communication and Dyadic communication are the ones that are between two people.

Dyadic communication is the one in which two people relate to exchange thoughts and ideas face-to-face. It is sometimes referred as dialogic relation.

Interpersonal relation can be between two or more than  two persons that may know each other. It is clearly specified in this communication that who listener and speaker are.

<h3>I hope it will help you!</h3>
3 0
2 years ago
Read 2 more answers
How do i protect my computer from electrical spikes
Setler [38]
I believe the answer is bloody purple poop that is the size of an extra large grilled cheese 
5 0
3 years ago
Read 2 more answers
When a program terminates because a thrown exception is not handled, the program:
castortr0y [4]

Answer:

Option (e)

Explanation:

Option (e) is the answer. It indicates the exception thrown and displays it. It also indicates the place where the exception was thrown ( at what line of the code the exception was thrown )

Option (a) is false as the program which was terminated because of an exception which was not handled doesn't starts automatically.

Option (b) is false as it doesn't opens a dialogue box about running the program another time or anything. It just terminates because of the unhandled exception.

Option (c) is false as it doesn't saves all the output to a disk file called the "runStackTrace.txt".

Option (d) is false as it doesn't open a dialogue box. The program terminates because of the unhandled exception.

4 0
2 years ago
Discuss operations of vectors in computer graphics?
Allushta [10]

Answer:

  In the computer graphics, the vectors are basically used to compose various type of components. In the computer graphics it is basically known as vector graphics and it is composed of various types of components.

The operation of the vector in the computer vector is that it is basically used to create the digital images by the use of mathematical statement and command.

It is used to place the lines and the shape in the two- dimension and three- dimension spaces. IN the computer graphics, vectors are also used to represent the particular direction of the various objects.

6 0
2 years ago
How do you use VMware Fusion to make a Tip Calculator?
lana66690 [7]
You have to subtract the tax amount by the final amount then multiply the result by the percentage of tip that is based on the service that you received.
4 0
3 years ago
Other questions:
  • The _____ element, a hypertext markup language (html) metadata element, contains a collection of metadata elements that describe
    11·2 answers
  • A network administrator is required to upgrade wireless access to end users in a building. To provide data rates up to 1.3 Gb/s
    12·1 answer
  • The 3 parts of the CPU are
    15·2 answers
  • Software that function as an electronic file cabinet
    7·1 answer
  • When an organization uses cloud computing, they do not have to buy and maintain expensive hardware. Group of answer choices True
    6·1 answer
  • Declare a variable temperature and initialize it to 98.6. Instructor Notes: Note that "initialize" means "declare and assign a v
    5·1 answer
  • Int a = 1; int b = 0; int c = -1; if ((b + 1) == a) { b++; c += b; } if (c == a) { a--; b = 4; }
    7·1 answer
  • What is a Computer ?and it's demerits​
    13·2 answers
  • How do science, mathematics, and technology each influence engineering
    9·2 answers
  • For angular how can we set up th edatabse.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!