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
When developing an estimate, which of the following items is typically marked up with the highest percentage rate?
dmitriy555 [2]

Answer: D. Labor

Explanation:

8 0
2 years ago
The type code for an int array is 'b'. What line of code creates an array of int data values?
Ilia_Sergeevich [38]

Answer:

intArray=array(’b’,[2,5,10])

Explanation:on edge

8 0
3 years ago
A network technician has configured a point-to-point interface on a router. Once the fiber optic cables have been run, though, t
masya89 [10]

Answer:

Wavelength Mismatch

Explanation:

Optical fiber cables are used because they have lowest attenuation(loss of signal strength).

Attenuation is directly proportional to wavelength.

According to me this issue is most likely caused by Wavelength mismatch.If the wavelength of the signal is high then there is more attenuation in that signal.

6 0
3 years ago
Write a program that plays the popular scissor-rock-paper game. (A scissor can cut a paper, a rock can break a scissor, and a pa
Andrei [34K]

Answer:

Explanation:

The following program is written in Python and follows all the instructions accordingly to create the rock paper scissor game as requested.

from random import randint

answers = ["Scissors", "Rock", "Paper"]

computer = answers[randint(0, 2)]

continue_loop = False

while continue_loop == False:

   

   player_choice = input("Choose a number, 0 = Scissors, 1 = Rock , 2 = Paper?")

   player_choice = answers[int(player_choice)]

   if player_choice == computer:

       print("Tie!")

   elif player_choice == "Rock":

       if computer == "Paper":

           print("You lose!", computer, "covers", player_choice)

       else:

           print("You win!", player_choice, "smashes", computer)

   elif player_choice == "Paper":

       if computer == "Scissors":

           print("You lose!", computer, "cut", player_choice)

       else:

           print("You win!", player_choice, "covers", computer)

   elif player_choice == "Scissors":

       if computer == "Rock":

           print("You lose...", computer, "smashes", player_choice)

       else:

           print("You win!", player_choice, "cut", computer)

   else:

       print("That's not a valid play. Check your spelling!")

   continue_or_not = input("Would you like to play again? Y/N")

   continue_or_not = continue_or_not.lower()

   if continue_or_not != "y":

       break

   computer = answers[randint(0, 2)]

8 0
3 years ago
What app/software is this? (edit vids)​
Yuki888 [10]
I think that is Filmora?
5 0
3 years ago
Other questions:
  • What sequence is used to create a brochure document from a template?
    8·2 answers
  • With a C program (memory map), data in _____ is initialized by the kernel to arithmetic 0 or null pointers before the program st
    7·1 answer
  • The memory locations listed in a procedure header's parameterList have procedure scope and are removed from the computer's main
    9·1 answer
  • Sam wants to move across the text and his documents to add data at predefined stops. Which key will Hughes to navigate through t
    6·1 answer
  • A python package used in text analysis and natural language processing. True or False
    10·1 answer
  • Untuk memberikan keterangan pada bagian bawah halaman dokumen yg akan diulangi pada setiap halaman dokumen yg digunakan fasilita
    8·2 answers
  • Which of the following describes an iteration in a computer program?
    8·1 answer
  • What is the purpose of the green flag in the Scratch interface?
    8·2 answers
  • Convert FA23DE base 16 to octal<br>​
    6·2 answers
  • The cost of an items is Rs 200. what will be the cost of 50 such items. write a simple program​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!