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]
3 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]3 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
the first thing to do when your computer gives you an error message is A restart the computer B press the F2 key C write down th
lesya692 [45]

Answer:

I think you should restart the computer

6 0
1 year ago
380<br> 787<br> What is380+787=
nignag [31]
The awnser is 1167 ..
7 0
3 years ago
Read 2 more answers
An analyst is reviewing the logs from the network and notices that there have been multiple attempts from the open wireless netw
prisoha [69]

Answer:

The description for the given question is described in the explanation section below.

Explanation:

The following facts underneath will avoid this form of attack:

  • Implement a VLAN to distinguish HVAC from a free wireless channel or network.
  • To secure the HVAC device mount IDS.
  • Let NAC on either the wireless system and network available.
  • Activate WPA2 sec on the mobile phone network.
4 0
3 years ago
The ____ operation is used to add an element onto the stack.
Mariulka [41]
A. the answer is push :) pop is when you take away
8 0
4 years ago
Animator or a scientist
klemol [59]

Answer:

animator

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Blank uses computer resources from multiple locations to solve a common problem.
    6·1 answer
  • Write a function named intro that takes a string as input.
    12·1 answer
  • Which device or software application detects errors in system configurations?
    8·1 answer
  • PLEASE HELP ITS EASY I JUST BIG STOOPYHEAD!!!!
    5·2 answers
  • How many bits are required to write decimal number?
    9·1 answer
  • the UDP server described needed only one socket, whereas the TCP server needed two sockets. Why? If the TCP server were to suppo
    8·2 answers
  • 1. What conversion factor should be used to convert from Gigaliters to liters?
    14·1 answer
  • While traveling in India, Sabina notes all of her daily expenses in rupees in her spreadsheet. At the end of the day, she wants
    6·1 answer
  • When you use the Query Editor to run a query that returns an xml type, theManagement Studio displays the XML data in blue with u
    13·1 answer
  • Question 3 10 points Save Answer Many companies in the computer industry introduce new products and services frequently in an at
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!