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]
2 years ago
11

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

Computers and Technology
1 answer:
barxatty [35]2 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 statements is the least abstraction of the world wide web
Sliva [168]
<span>Documents, images and other data you can access by providing a uniform Resource Locator. URL - the Web Address

I hope this helps. You didn't give me the choices to from.  </span>
8 0
3 years ago
Read 2 more answers
Complete two examples of how scientists, technologists, engineers, and mathematicians may work together to create a new product
asambeis [7]

Answer:

By thinking of ways to create environment friendly products such as biodegradable water bottles

3 0
2 years ago
You have an interface on a router with the ip address in the class c network subnet of 192.168.192.10/29. how many total host ad
Gemiola [76]
If 29 bits of the 32 available addressing bits are used for the subnet, then only 3 bits giving 2^3=8 combinations remain for the host addresses. 

In reality, the all zeros and all ones addresses are reserved. So, 8 addresses can exist, but 6 of those are available.

The way the question is formulated it seems the answer 8 is what they're after.
8 0
3 years ago
True or false As the contents and topics of new magazines change year-to-year, you can see various trends and movements across s
Tamiku [17]

the short answer is true.

The long answer is that magazines can help shape and invent new trends.  like they have time and time again in the past.

Hope this helps

-scav

8 0
2 years ago
Does downloading from mega connect someone to your computer
lesantik [10]

Answer:

no

Explanation:

click on the picture to make it bigger

4 0
3 years ago
Other questions:
  • __ means having a current knowledge and understanding of computers, mobile devices, the web, and related technologies.
    8·1 answer
  • fill down feature on a formula and you need to keep a cell reference the same which one will allow you to keep the same cell ref
    15·1 answer
  • You were fortunate to get the ice off of the wings, but whatever caused the cabin to depressurize also vented all of your fuel o
    11·1 answer
  • What are the binary symbols?
    5·2 answers
  • Who where the romanovs? What happened to them ?
    7·1 answer
  • In a meeting, Juan hears someone say a product mix is "wide." What does
    13·1 answer
  • Write a static method named contains that accepts two arrays of integers a1 and a2 as
    14·1 answer
  • I'm bad i'm mrs puff doo doo doo yeah it's a holiday
    6·2 answers
  • What is the name of the programming language created by Spu7Nix?
    13·2 answers
  • Lily obtained data from five trails 50 kcal 72 kcal 12 kcal and 50 kcal which best decribes her data
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!