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
Ideally, how long or how many sentences should your video game pitch be?
Olin [163]
Good shot hdhhdbsb suhsbsbs bbsbsbsbdbbdbdbdbdbbd
6 0
3 years ago
Consider a class called Rocket that has a private instance variable called Engine. You are writing a "getter" for the Engine. Us
dusya [7]

Answer:

when user wants duplicate copy of the object

Explanation:

Encapsulation are one of the key foundations of object-oriented programming (OOP). It involves the bundling of data or information with the methods and various techniques which operate on that data.

It can be used in hiding the true values or state of a structured data object that is in a class, preventing unauthorized parties' direct access to them.

The circumstances that can be allowed in returning a reference to the existing Engine is when user wants duplicate copy of the object.

4 0
3 years ago
A Function checkMe takes three parameters, a character and two integers. If the sum of the two integers is negative, and the cha
Paul [167]

Answer:

Check the explanation

Explanation:

Here is the program with function definition and two sample calls.

Code:

#include <iostream>

using namespace std;

//checkMe FUNCTION which takes values a, b and c

void checkMe(char &a, int &b, int &c)

{

//if sum of b and c is negative and a is 'n', b and c are set to 0, otherwise a is set to 'p'

if((b+c)<0 && a=='n')

{

b = 0;

c = 0;

}

else

{

a = 'p';

}

}

int main()

{

//first test case when else part is executed

char a = 'n';

int b = 5;

int c = 6;

 

checkMe(a, b, c);

 

cout<<a<<" "<<b<<" "<<c<<endl;

 

//second test case when if part is executed

a = 'n';

b = -4;

c = -5;

 

checkMe(a, b, c);

 

cout<<a<<" "<<b<<" "<<c<<endl;

return 0;

}

Kindly check the Output below:

7 0
3 years ago
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
natka813 [3]

Answer:

tyhgfrd

Explanation:

8 0
3 years ago
An engineer plans to acquire data from a disk. The disk is connected to the forensics workstation and is ready for the engineer.
aksik [14]

The correct steps that indicate a correct order of acquisition as they relate to integrity and non-repudiation are:

  • A hash of the disk is made
  • A bit-by-bit copy is made
  • A second hash is made
  • A copy is made of the reference image

<h3>Is non-repudiation an aspect of integrity?</h3>

In general, nonrepudiation is known to be a term that puts together or combines authentication and integrity.

Note that Nonrepudiation is said to be a key or one of the pillars that pertains to information assurance.

The integrity in cyber security is known to be the act of keeping safe against any form of an improper information modification or destruction.

Hence, The correct steps that indicate a correct order of acquisition as they relate to integrity and non-repudiation are:

  • A hash of the disk is made
  • A bit-by-bit copy is made
  • A second hash is made
  • A copy is made of the reference image

Learn more about acquisition from

brainly.com/question/11412887

#SPJ1

8 0
2 years ago
Other questions:
  • Which of the following is a justification for giving a Page Quality (PQ) rating of Lowest? Select all that apply. True False The
    7·1 answer
  • A(n) _____ can be used to convert digitized documents into ascii (american standard code for information interchange) text that
    6·1 answer
  • HELP ME PLZ QUICK Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took
    6·1 answer
  • Which of the following is true of how packets are sent through the Internet?
    11·2 answers
  • What is the google search operator that limits results to a specific domain?
    8·1 answer
  • What is a common translator?​
    9·1 answer
  • Write the two features of a mouse.​
    9·1 answer
  • If 209g of ethanol are used up in a combustion process, calculator the volume of oxygen used for the combustion at stp​
    5·1 answer
  • Imagine that you are creating a website for a client. How will you interact with the client, gather requirements, and update the
    7·2 answers
  • It is important to consider design details when creating an api because: ______________
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!