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
telo118 [61]
2 years ago
15

. Write a short program that asks the user to input a string, and then outputs the

Computers and Technology
1 answer:
Mice21 [21]2 years ago
7 0

Answer:

// program in java.

// package

import java.util.*;

// class definition

class Main

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // object to read input from user

Scanner scr=new Scanner(System.in);

System.out.print("Enter a string:");

 // read input

String myString=scr.nextLine();

 // variable to store characters count

int char_count=0;

 // count the characters

for(int i = 0; i < myString.length(); i++) {

           if(myString.charAt(i) != ' ')

               char_count++;

       }

       // print the number of character

System.out.println("total characters in the String: "+char_count);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Read a string from user with the help of Scanner object and assign it to variable "myString".Iterate over the string and if character is not space (' ') then char_count++. After the loop print the number of characters in the string.

Output:

Enter a string:hello world

total characters in the String: 10

You might be interested in
Which of the following is NOT necessary for organizing data to make it easier to sort?
Elenna [48]

Answer:

All the data must be the same font and font size is not necessary for data sorting.

Explanation:

The most easier and frequently used tool for data organizing and sorting is Microsoft's excel or google spreadsheet. Sorting deals with arrangement of  data values in a particular sequence or order according to defined rules. For example data can be sort in ascending or descending order as per values or names in list.

7 0
3 years ago
Suppose a worker needs to process 100 items. the time to process each item is exponentially distributed with a mean of 2 minutes
stiks02 [169]
Suppose a worker nneeds to process100 items
7 0
3 years ago
Endnotes into a document are automatically positioned at the bottom of the page where the endnote reference is inserted.
dezoksy [38]
I think false hope its right
3 0
3 years ago
Why are there so many unit testing tools? Are they efficient? Why or why not?
sineoko [7]

Answer:

 Unit testing is the software testing method in which the individual source code are associate to control data. Unit testing basically test the code to ensure that the data or information meets its design.

The aim of unit testing that each part isolate in the program and display the correct individual parts.

Unit testing tool are efficient as they provide several benefits in the development cycle. The basic efficiency of unit testing tools depend upon its type of testing. Unit testing basically validate the units of source code in the program.

For example: when the loop and function in the program work efficiently.

5 0
2 years ago
The internet is ________. an internal communication system for businesses a large network of networks a communication system for
uranmaximum [27]

A large network of networks

<h3>What Is a large network?</h3>
  • It is the biggest network that connects computers across the world. With the internet, people can share data and files over the internet. The Internet is defined as a network of networks Hence it is the correct option

To learn more about the network, refer

to https://brainly.in/question/32165678

#SPJ4

4 0
1 year ago
Other questions:
  • Find the cell address of first column and last row some one pls answer :'(​
    9·1 answer
  • What would be some long- term goals.
    11·1 answer
  • What type of program would use to create a personal budget?
    14·1 answer
  • What are the pros and cons of editorial anonymity in Wikipedia
    10·2 answers
  • For questions 19 - 21, assume that Student, Employee and Retired are all subclasses of Person, and all four classes have differe
    9·1 answer
  • In Excel, you can sort a table by one or more columns by.
    7·1 answer
  • You do not really know that you have a hand. Here is why. Imagine the possibility in which you are only a handless brain floatin
    14·1 answer
  • What is pollution?
    14·2 answers
  • Write any two rules for writing algorithm​
    10·1 answer
  • Which of these is a possible disadvantage of working with a team?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!