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
Which of the following is the core of an operating system that maintains the computer’s clock, starts applications, and assigns
bagirrra123 [75]
The answer is the Kernel.
In computing, the Kernel's job is to manage the I/O requests from the software on your computer and converts them into data processing instructions for the CPU (Central Processing Unit) and the rest of the electronic components of a computer.
 
4 0
3 years ago
Information to develop a project network is collected from the.
Kryger [21]

Information to develop a project network is collected from the work breakdown structure

<h3>Work breakdown structure </h3>

Work breakdown structure (WBS)  is a structure showing the steps needed to be taken so as to complete a project.

WBS is presented in visual format and it is usually arranged based on hierarchy.

Information to develop a project network is collected from the work breakdown structure

Find out more on Work breakdown structure at: brainly.com/question/6197566

7 0
2 years ago
ANSWERED CORRECT BELOW
ch4aika [34]

Answer:

Explanation:

The Java code provided in the question works as intended. The nextInt() correctly outputs the random value from 1-10 while the nextInt(int min, int max) correctly outputs random values between the int and max parameters. I changed the int/max arguments to 3 and 12 and ran the program to demonstrate that the program is running as intended. Output can be seen in the attached picture below.

8 0
3 years ago
The operations planning practice of inputting sales forecasts into computer software that accurately predicts the amount and tim
netineya [11]

Answer:

"Materials requirement planning" is the correct answer for the above question.

Explanation:

  • The "Materials requirement planning" is a software system that is used to hold the record of the raw materials.
  • It is used to tell about the material which is present in the stocks. It also used to schedule the delivery.
  • This software is used to enhance the productivity of the company.
  • The above question asked about the software which is needed to keep the record of the raw material. This software is known as "Materials requirement planning".
3 0
3 years ago
Choose the best answer from the options below to complete the following sentence.
Lemur [1.5K]

Answer:

its A. the answer to your question is preserved. :)

7 0
2 years ago
Other questions:
  • for which is a chart legend used? a.all of the time b.whenever you are comparing data that is the same c.whenever you are compar
    9·2 answers
  • A technician is configuring a new SOHO multifunction wireless router at a customer’s location to provide network access to sever
    12·1 answer
  • Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
    11·1 answer
  • ​Suppose your computer network was compromised in a large scale virus attack last Thursday. Most of the data files got corrupted
    8·1 answer
  • You are utilizing BitLocker Drive Encryption, and are attempting to update Windows Server 2016. What must be done so that the up
    14·1 answer
  • Define a constructor as indicated. Sample output for below program:Year: 0, VIN: -1Year: 2009, VIN: 444555666// ===== Code from
    8·1 answer
  • Can somebody help me out
    15·1 answer
  • Mark is flying to Atlanta. The flight is completely full with 200 passengers. Mark notices he dropped his ticket while grabbing
    15·1 answer
  • Find the unknown quantities
    12·1 answer
  • What is the value of x after running this code?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!