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
manufacturers are making an effort to build energy-efficient computers and use recyclable cases and packaging true or false
Fittoniya [83]
True would be ur answer

Hope I helped:P
7 0
3 years ago
Prevent a page break in the final paragraph of this document by keeping the lines together
sineoko [7]

Answer:

1. Place your cursor in the General Provisions section towards the finish of the archive.  

2. On the Page Layout tab, in the Paragraph gathering, tap the Paragraph Dialog Box Launcher and afterward tap the Line and Paragraph Breaks tab.  

3. Select the Keep lines together checkbox and snap Ok.  

Explanation:

In a short report or one that doesn't require a complex navigational structure, you can without much of a stretch configuration words and sections so key focuses emerge and the structure of your record is clear. You can accomplish sensational by applying predefined Word Art content impacts. To keep the presence of reports and other Microsoft Office records steady, you can organize archive components by applying predefined sets of designing called styles. Moreover, you can change the textual styles, hues, and impacts all through a record with a single tick by applying a subject.

7 0
3 years ago
Help please not trying to fail
deff fn [24]

Answer:

B. Everywhere CFCI is not

8 0
3 years ago
When you save a drawing using paint, it's automatically stored as a?
serious [3.7K]

Answer:

Bitmap File

Explanation:

6 0
3 years ago
Power brakes:
IgorLugansk [536]
The answer is B becausePower brakes are a system of hydraulics used to slow down or stop most motor vehicles. It uses a combination of mechanical components to multiply the force applied to the brake pedal by the driver into enough force to actuate thebrakes and stop a vehicle that can weigh several tons.
5 0
3 years ago
Read 2 more answers
Other questions:
  • Waterpower was first harvested by ancient societies using
    5·1 answer
  • How can I sent a message?
    13·1 answer
  • What inventor patented the first american movie projector
    15·2 answers
  • Keyboard question: <br> How do I make the 'congruent to' symbol on this keyboard?
    8·1 answer
  • What did Charles Babbage design in 1822 to substitute values in polynomial equations? ENIAC TRADIC Analytical Engine Difference
    6·1 answer
  • All of the following are strategies to help you prepare for standardized test except <br>​
    5·1 answer
  • You can count on everything online to be 100% accurate. <br> A. FALSE <br> B. TRUE
    11·2 answers
  • Adam's interview with the hiring manager is going well. However, he wants to ensure that his skills and work history are memorab
    6·1 answer
  • Which of the following is one of the tools in REPL.it that helps prevent syntax errors?
    10·1 answer
  • I need to send this in ASAP
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!