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
What does VERONIcA stand for?
kompoz [17]
Very Easy Rodent-Oriented Netwide Index to Computerized Archives
5 0
4 years ago
Read 2 more answers
You can use view the ______ file to view the hard drive details.
Anastaziya [24]

Answer:

/proc/partitions

5 0
3 years ago
We have stressed the need for an operating system to make efficient use of the computing hardware. When is it appropriate for th
4vir4ik [10]

Answer:

Explanation: This seems more like an opinion answer so give your opinion, try yout best, just trying to help ;)

5 0
3 years ago
Read the scenario below. Explain why this is not fair use of copyright materials. What should you do instead of using the entire
Thepotemich [5.8K]

Answer:

You did not buy the rights to the copyrighted material when you bought it from Apple Music

Explanation:

When you bought the song from Apple Music, you paid them for your using of the song to listen to, as stated in the agreement that you wouldve been required to agree to. Apple is only allowed to provide the material for personal use to its users, with it part of its fees going to the original copyright holders.

8 0
4 years ago
You are designing an exciting new adventure game and you want to attempt to explain where items that are carried by the player a
alukav5142 [94]

Answer:

hYou are designing an exciting new adventure game and you want to attempt to explain where items that are carried by the player are being kept. What inventory system should you use to this? O visual grid approach hyperspace arsenal weighted inventory pseudo-realistic​

Explanation:

6 0
3 years ago
Other questions:
  • Erica is working at a real estate office. She would like to organize the information about houses they have for sale. Erica shou
    13·2 answers
  • Does group policy management matter without a server environment?
    7·1 answer
  • Click ____ to move a stacked object to the top of the stack. Move to Top Bring to Front Slide to Top Move to Front
    12·1 answer
  • Add three methods to the Student class that compare twoStudent objects. One method should test for equality. A second method sho
    13·1 answer
  • If a simple pipelined processor is super-pipelined by a factor of 3 (the ALU takes 3 cycles instead of one for the smallest oper
    15·1 answer
  • People who score high on the Big Five trait dimension of ________ tend to use more adjectives in their e-mail communications. Gr
    15·1 answer
  • Which of the following statements about federal student loans is true?
    7·1 answer
  • Hello everyone. New ppl on Ro.blox? I want to play sometime.
    11·1 answer
  • If there is an int/integer in a array, and the same int/integer comes at the same spot, does it cancel each other out or does it
    14·1 answer
  • FIRST TO Answer for free brainlest. GOG GOGOGO
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!