Question

Write a program that removes all spaces from the given input. Ex: If the input is:...

Write a program that removes all spaces from the given input. Ex: If the input is: Hello my name is John. the output is: HellomynameisJohn.

The program needs to be in Java

Homework Answers

Answer #1

Source Code- In JAVA

import java.util.Scanner;

class Main {
  public static void main(String[] args) {

    // create an object of Scanner
    Scanner scr = new Scanner(System.in);
    System.out.println("Enter the string of your choice");

    // take the input
    String input = scr.nextLine();
    System.out.println("Original String: " + input);

    // remove white spaces
    input = input.replaceAll("\\s", "");
    System.out.println("Final String: " + input);
    scr.close();
  }
}

Hope I answered the question.

If you have any doubts, or queries, feel free to ask

I'll respond to you as soon as I can.

Have a nice day

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program that takes in a line of text as input, and outputs that line...
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text. Ex: If the input is: Hello there Hey quit the output is: ereht olleH yeH IN JAVA
1. Write a Java program to count the letters, spaces, numbers and other characters of an...
1. Write a Java program to count the letters, spaces, numbers and other characters of an input string. 2. Write a Java program to print numbers between 1 to 100 which are divisible by 3, 5 and by both 3. Write a Java program to convert a given string into lowercase
Write a program in C that extracts the tokens from a string. Given a string as...
Write a program in C that extracts the tokens from a string. Given a string as input, the program should print on the screen each token on a new line. For example given the following string as input: “hello there my friends” the program should generate: I am a programmer
Write a program in python to display all the consonant in the user input. E.g. user...
Write a program in python to display all the consonant in the user input. E.g. user input: Hello Good Day to you. Output: consonant H = 1 consonant l = 2 consonant G = 1   consonant d = 1 consonant D = 1 etc
JAVA: Write a program that takes in a line of text as input, and outputs that...
JAVA: Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters “done” (case-insensitive) for the line of text. Note: You are not supposed to use any in-build methods to reverse the text. Example: Enter a series of strings: Hello there Hey done the output is: ereht olleH yeH
Write a complete Java program which prompts the user of the program to input his/her first...
Write a complete Java program which prompts the user of the program to input his/her first name, then prompts the user for the middle initial and finally prompts the user for the last name. As indicated, there are three prompts to the user. The program should output the user’s name with the first name first, followed by the middle initial, and the last name last, all on one line (with appropriate spacing). If you could also pinpoint exactly where to...
Given this input, write the python code that returns the specified output Input X= ["This is...
Given this input, write the python code that returns the specified output Input X= ["This is a wolf #scary",     "welcome to the jungle #missing",     "11132 the number to know",     "Remember the name s - John",     "I      love      you"] Output This is wolf scary welcome to the jungle missing the number to know Remember the name John I love you
In JAVA: Write a program that reads an integer, a list of words, and a character....
In JAVA: Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character. Assume that the list of words will always contain fewer than 20 words. Ex: If the input is: 4 hello zoo sleep drizzle...
Language is Java Name format Many documents use a specific format for a person's name. Write...
Language is Java Name format Many documents use a specific format for a person's name. Write a program whose input is: firstName middleName lastName and whose output is: lastName, firstInitial.middleInitial. Ex: If the input is: Pat Silly Doe the output is: Doe, P.S. If the input has the form: firstName lastName the output is: lastName, firstInitial. Ex: If the input is: Julia Clark the output is: Clark, J.
A palindrome is a word or a phrase that is the same when read both forward...
A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome. Ex: If the input is: bob the output is: bob is a palindrome The code needs to be in Java.