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 appears in the document after you have inserted a video?
Nitella [24]

Answer:

text with a hyperlink to the video website

Explanation:

documents do not auto-upload thumbnails or embedded videos for playback, so external links are pasted there

6 0
3 years ago
Read 2 more answers
Which framework can be used to develop cross-platform applications?
k0ka [10]

Answer:

Qt framework

Explanation:

3 0
3 years ago
Determine the output of the following code segment:
Nataly [62]

Answer:

The output to the given code as follows:

Output:

10

100

64

36

16

4

0

4

16

36

64

Explanation:

In the given java code, an integer variable "i" and an array number is defined, which size is 10, in the next step two for loop is declared, that can be described as follows:

  • In the first loop, array use loop variable "i" use, which minus the value of 5 and multiplies by 2, and it will calculate the square of that number.
  • In the next step, a for loop is declared, that prints these array number variable square.
7 0
4 years ago
A(n) ____________ is a private data network that creates secure connections over regular internet lines.
Setler79 [48]
VPN is the correct answer
5 0
4 years ago
What is the most secure method for controlling privileged access to a system available for use in a public area?a. Database view
Lorico [155]

Answer:

Constrained user interfaces is the correct answer to the following question.

Explanation:

Because Constrained user interfaces are the secured function that is used for controlling the access of the user to the computer system and also confines the user to access the data but they can access only that data for which they are not restricted. In other words, Constrained user interfaces is that type of restriction for those users who access your data or resources and they can access only that part of data for which they are allowed.

4 0
3 years ago
Other questions:
  • What characteristics need to be exhibited by an organisation to improve its software process?
    7·1 answer
  • A ____________________ can be used to hierarchically represent a classification for a given set of objects or documents. A. taxo
    10·1 answer
  • Dzięńdobry kto ogarnia komędy w minicraft bardzo dobrze i by mi pomógł w stworzeniu serwera [dostanie w zamian range właścieciel
    5·1 answer
  • What is the code name for the 12 engineers who developed the ibm pc?
    8·1 answer
  • Define the following term. data, database, DBMS, database system, data- base catalog, program-data independence, user wen', DBA,
    12·1 answer
  • What is a characteristic of maintaining logs in a system? A. Logging prevents security violations, but only deals with passive m
    10·1 answer
  • Which is better? iPhone 11 Pro Max or Samsung Galaxy Note 20 Ultra 5G and why?
    12·2 answers
  • How to get off of supervised user
    7·1 answer
  • What can a user modify on a business card using the Edit Business Card dialog box? Check all that apply.
    6·1 answer
  • What is geolocation?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!