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
marishachu [46]
3 years ago
11

(1) Prompt the user to enter a string of their choosing. Output the string.

Computers and Technology
1 answer:
barxatty [35]3 years ago
6 0

Answer:

See solution below

See comments for explanations

Explanation:

import java.util.*;

class Main {

 public static void main(String[] args) {

   //PrompT the User to enter a String

   System.out.println("Enter a sentence or phrase: ");

   //Receiving the string entered with the Scanner Object

   Scanner input = new Scanner (System.in);

   String string_input = input.nextLine();

   //Print out string entered by user

   System.out.println("You entered: "+string_input);

   //Call the first method (GetNumOfCharacters)

   System.out.println("Number of characters: "+ GetNumOfCharacters(string_input));

   //Call the second method (OutputWithoutWhitespace)

   System.out.println("String with no whitespace: "+OutputWithoutWhitespace(string_input));

   }

 //Create the method GetNumOfCharacters

   public static int GetNumOfCharacters (String word) {

   //Variable to hold number of characters

   int noOfCharactersCount = 0;

   //Use a for loop to iterate the entire string

   for(int i = 0; i< word.length(); i++){

     //Increase th number of characters each time

     noOfCharactersCount++;

   }

   return noOfCharactersCount;

 }

 //Creating the OutputWithoutWhitespace() method

 //This method will remove all tabs and spaces from the original string

 public static String OutputWithoutWhitespace(String word){

   //Use the replaceAll all method of strings to replace all whitespaces

   String stringWithoutWhiteSpace = word.replaceAll(" ","");

   return stringWithoutWhiteSpace;

 }

}

You might be interested in
Please help!!!
Alchen [17]

The most probable reason why your code for the dog turning right instead of is because your conditional statements are not satisfied.

<h3>What is Debugging?</h3>

This refers to the identification and removal of errors in a given code or hardware component.

Hence, we can see that you should note that you are using teh ifElse conditional statement to execute your code and you stated that the dog would turn right if:

  1. The left side is blocked
  2. If there are balls present.

Therefore, there are balls present and also the left side is blocked which causes your dog to turn right because it is executing the else statement.

Read more about debugging here:

brainly.com/question/16813327

#SPJ1

6 0
2 years ago
What do rocket scientists mean when they say, "forces come in pairs?"
zhenek [66]
According to Newton's third law, for every action force there is an equal (in size) and opposite (in direction) reaction force.
6 0
3 years ago
What is a scenario where records stored in a computer frequently need to be checked
vazorg [7]

if your in  school and always are getting into trouble the school will always be checking your records


7 0
3 years ago
Read 2 more answers
When the writer of a letter sends a copy to a third party without the knowledge of the person receiving the original letter, it
ahrayia [7]

The answer here is Blind carbon copy (bcc).

The original recipients of the letter are unable to see (blind) who else receives a copy if those parties are on the bcc list.

3 0
3 years ago
When sending a file as an e-mail attachment, the save &amp; send option can be found by clicking on which tab? insert file home
aleksklad [387]
I belive that it is .insert.
5 0
2 years ago
Other questions:
  • At the dsl local carrier's office, the __________ demultiplexes the data streams and converts them into digital data.
    10·1 answer
  • What operator is used to create a validation rule? A. – B. / C. &lt; or &gt; D. +
    12·1 answer
  • Create a style rule for the page body that sets the width to 95% of the browser window ranging from 640 pixels up to 960 pixels.
    11·1 answer
  • What step can Miguel take to solve his dilemma? Miguel is working on a project that requires him to switch back and forth freque
    12·2 answers
  • Which tab in Microsoft Word provides access to the backstage view?
    8·2 answers
  • While you are working on your computer, it shuts down unexpectedly, and you detect a burning smell. When you remove the case cov
    10·1 answer
  • How acid rain pollution will affect the food chain
    15·2 answers
  • Write a program that allows the user to enter their name from the keyboard. Allow the user to pick how many times they want thei
    12·1 answer
  • What is the value of the variable result after these lines of code are executed? &gt;&gt;&gt; a = 5 &gt;&gt;&gt; b = 2 &gt;&gt;&
    8·2 answers
  • A company is looking for an employee to assign passwords to all of its
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!