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
Which of the following is not a use of a hash function
soldi70 [24.7K]

Answer:

the answer would be there

Explanation:

7 0
3 years ago
One purpose of fairy tales is to help children master the problems associated with growing up. Please select the best answer fro
-Dominant- [34]

Answer:

The answer is TRUE

Explanation:

7 0
3 years ago
Read 2 more answers
Who is this person?<br><br><br> Kaneppeleqw. I see them everywhere. Are they a bot? Are they human?
Effectus [21]
I’m not sure. Maybe a human.
6 0
3 years ago
How will you be assigned with a mailbox with any OSP
Leona [35]

Answer:

Go to the File tab and click Options.

Click on the Mail menu at the left.

Click on the Signatures button to open the Signatures and Stationary window.

In the Email Signature tab, click New.

Type in a name for the New Signature such as Shared Mailbox Signature and click OK.

Explanation:

3 0
3 years ago
Your computer is taking longer than usual to open files and you notice that your hard drive light stays on longer than usual. Wh
777dan777 [17]
There might be insufficient storage space so your computer usually takes a longer time to load.The bigger your file, the longer it takes to load. So the solution is to clear up your storage space



7 0
3 years ago
Other questions:
  • What feature is required to send data from a web-connected device (like a point-of-sale system) to Google Analytics?
    14·1 answer
  • Which of the following is a beneficial reason to extract mineral resources from the earth?
    13·2 answers
  • This document shows a student's education and career goals and a way to achieve those goals.
    8·1 answer
  • _________________ component defines the correct granularity for access controls and oversees the relationships between identitie
    13·1 answer
  • I AM GIVING BRAINLIEST!!!!!!! PLEASE HELP !!!!!!!!
    7·2 answers
  • Select all the correct answers.
    6·1 answer
  • G i r l s o n l y j o i n <br> id= ons jcuv jke
    13·2 answers
  • Which element of the MakeCode Arcade interface represents an individual
    12·1 answer
  • When did Microsoft released MS-Word 2016? S When did Microsoft released MS - Word 2016​
    7·1 answer
  • What is a Type 10 SD card?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!