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
Panes created using the vertical split bar scroll together horizontally. true or false.
Nataly_w [17]
I think the statement given above is false. Panes created using the vertical split bar do not scroll together horizontally. <span>The two </span>panes scroll together vertically, but scroll<span> independently </span>horizontally<span>. Hope this answers the question. Have a nice day.</span>
4 0
3 years ago
Choose the missing term.
qaws [65]

Answer:

import

Explanation:

the <em>import </em>keyword is used to import external modules into a python script.

6 0
2 years ago
PHP is based on C rather than ______.
Maksim231197 [3]

Answer:

2b2t

Explanation:

2b2t

8 0
3 years ago
HELP PLX ITS PYTHON BTW!!!
ExtremeBDS [4]

Answer:

Sebastian is your last name diaz

Explanation:

Functions allow us to break our program into multiple parts

Multiple is the answer

Atlanta-Robinson

5 0
3 years ago
_ effects determine how slide elements disappear
kupik [55]
<span>Exit effects determine how slide elements disappear. </span>
6 0
3 years ago
Other questions:
  • A(n)________________ is something that goes into a system a resource such as time,money,communication,etc
    10·1 answer
  • The ____________________ packet-filtering firewall allows only a particular packet with a particular source, destination, and po
    10·1 answer
  • If Denise specifies Jan? as a search criterion, Excel will locate all of the following records EXCEPT ____.
    9·1 answer
  • Enter the number 2568 into the box below
    14·1 answer
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    8·1 answer
  • Please help! 40 points + Brainliest!
    8·1 answer
  • Describe how learning can be accessed in your class?​
    14·1 answer
  • Your friend has a great idea for a new app, and she shows you a document that outlines what the app will do. This document is an
    6·1 answer
  • My phone takes forever to load the ads, does anyone else have this problem? Is there a way to fix it? I’ve tried getting another
    12·2 answers
  • Which of these is a type of social engineering attack?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!