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
HELPPPPPOOP
alexgriva [62]

Answer:b

Explanation:

8 0
2 years ago
Why is the total number of cylinders in an engine an even number?
gogolik [260]
Well there are 4 cylinders but there are also, 6, 8, 12, 16
5 0
3 years ago
Green computing can be achieved by: a. using video conferencing, electronic meeting systems, and groupware. b. replacing meeting
Rama09 [41]

Answer: using video conferencing, electronic meeting systems, and groupware

Explanation:

Green computing simply means the use of computer in a way that's environmental friendly.

One way to achieve this is through using video conferencing, electronic meeting systems, and groupware. This allows the use of computers not to have a negative effect on the environment.

4 0
3 years ago
In DTP, a good rule of thumb is to use as many special effects as you need to make your documents look interesting.
Margarita [4]
It all depends back on who youre present it t

younger ages (Primary-Middle),
Its Ok to use plenty of special effects, but dont ovedue your DTP with effects, so that they still can get the point.

Older ages (High & above)
Older people usually more serious than older ages to pursue their careers, so less effect, more points


5 0
3 years ago
Why do you lose internet access when you alter the arp to a static address?
Mila [183]
Sometimes you lose internet access because by altering the arp to a static address, there is change during that so u usually lose the i internet access [ hope i’m right ]
6 0
3 years ago
Read 2 more answers
Other questions:
  • In your Ice Breakers game, when does the player lose a life?
    6·2 answers
  • What 3 types of technologies are used inside hard drives?
    15·1 answer
  • Describe how data center storage applications drive the development of SAN technology.
    8·1 answer
  • Explain how it makes you feel that you must share the road with others
    15·1 answer
  • What are 2 main differences betweenarrays andstructs?
    7·1 answer
  • Firewall ____ indicate whether a large number of echo messages are being received.
    9·1 answer
  • What goals do you set for yourself while studying?
    9·2 answers
  • Why should you list more than one font if you are formatting some text using CSS?
    10·1 answer
  • Write a function called changeCharacter that takes three parameters – a character array, its size, and the replacement character
    15·1 answer
  • To what extent do you agree with the assertion that “Collection development begins with community analysis”. (Give reasons to bu
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!