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
What is the differnce between ''P4 and 4P''
34kurt
The number and letter are switched. This question needs more context to get a accurate answer.
5 0
3 years ago
Read 2 more answers
Before entering a loop, the first input, or ____, is retrieved.
Virty [35]

Loop is a control structure that causes a statement or group of statements to repeat.Before entering a loop, the first input, or the accumulator where the total will be kept is retrieved to an initial value, usually zero.

3 0
3 years ago
Explain the major innovation made from the establishment of abacus to present 5th computer generation.
ikadub [295]

Answer:

  1. Calculation using fingers
  2. Abacus (6th century BC)
  3. Sieve of Eratosthenes (3rd century BC)
  4. Napier bones
  5. slide rule
  6. Schikard's calculating clock with gears
  7. Pascaline
  8. Stepped reckoner by Leibniz
  9. Jacquard loom
  10. Mechanical computation machines (19th century)
  11. Analog computers (first half of 1900-1940)
  12. Digital computers (1940-1970)
  13. Computers with Microprocessors (1970 onwards)
  14. Smartphones (1992 onwards)

6 0
3 years ago
What was the original name of the Dream SMP?
Naddik [55]

Answer:

Dream Team SMP

Explanation:

7 0
1 year ago
Read 2 more answers
Define a function called strip_punctuation which takes one parameter, a string which represents a word, and removes characters c
DaniilM [7]

Answer:

punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']

def strip_punctuation(strWord):

   for charPunct in punctuation_chars:

       strWord = strWord.replace(charPunct, "")

   return strWord

Explanation:

The function is defined with a single argument.

A for loop is ran to check each character of the the word.

If a punction mark is present as a character in the word, it is removed.

The same word is returned but without the punctuation marks.

8 0
3 years ago
Other questions:
  • A type of malicious code that appears to be a safe program but that actually has a hidden purpose is called a _____.
    7·2 answers
  • Convert 234.43 (base 7) to base 10
    7·1 answer
  • A bookmarking site is a website that enables members to manage and share media such as photos, videos, and music. true or false
    14·1 answer
  • On a spreadsheet, this is the term for a grouping of cells that touch each other and form a rectangle. An example of it would be
    13·1 answer
  • Which of the following software programs provides for e-mail communication?. A. Access. B. Word Perfect. C. Outlook. D. Excel
    15·2 answers
  • A personal business letter is a letter that is ____.
    13·1 answer
  • Software that gives network administrators the ability to provide computer assistance from a central location by allowing them t
    15·1 answer
  • A technician has been notified of a problem on the network. After investigation, the technician determines that a specific inter
    7·1 answer
  • What is lasso tool write the name of any modelling and animation software<br>​
    8·1 answer
  • In which situation is coauthoring of presentations primarily utilized?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!