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
Juliette [100K]
3 years ago
13

Write a method that checks whether the input string or a sentence (a string with spaces) is a palindrome or not. The method shou

ld be case insensitive and should ignore spaces. Write a test program that prompts the user to input a string and invokes this method. Some example runs are: Enter the input string: madam Input string madam is a palindrome Enter the input string: banana Input string banana is NOT a palindrome Enter the input string: Race Car Input string Race Car is a palindrome Enter the input string: Too HOT to hoot Input string Too HOT to hoot is a palindrome
Computers and Technology
1 answer:
AURORKA [14]3 years ago
5 0

Answer:

import java.util.Scanner;

public class Pallindrome {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter the input string: ");

       String word = in.nextLine();

       System.out.println(isPallindrome(word));

   }

   public static String isPallindrome(String word){

       String rev ="";

       int len = word.length();

       for ( int i = len - 1; i >= 0; i-- )

           rev = rev + word.charAt(i);

       if (word.equals(rev))

           return word+" is palindrome";

       else

           return word+ " is not palindrome";

   }

}

Explanation:

  • Create the method in Java to receive a String parameter
  • Using a for loop reverse the string
  • Use another for loop to compare the characters of the original string and the reversed string
  • If they are equal print palindrome
  • else print not palindrome
  • Within the main method prompt user for a sentence
  • Call the method and pass the sentence entered by user
You might be interested in
Public static String doSomething(String s) { final String BLANK = " "; //BLANK contains a single space String str = ""; //empty
storchak [24]

Answer:

D. It returns a String that is equivalent to s with all its blanks removed

Explanation:

3 0
3 years ago
How do we “read” and “write” in MAR and MDR memory unit, please help I am very confused :)
Nutka1998 [239]

Answer:

No entiendo

Por favor traduce al español

6 0
3 years ago
which kind of device does a computer need in order to provide information to a person or something else
marin [14]
You would have to have the Internet
3 0
3 years ago
What do you call the quality of information
Kobotan [32]

Answer:

"Information quality" is a measure of the value which the information provides to the user of that information. accuracy, objectivity, Believability, reputation.

Explanation:

8 0
3 years ago
Hybrid processors that can process 32 bits or 64 bits are known by what term?
patriot [66]
For the answer to the question above asking, what h<span>ybrid processors that can process 32 bits or 64 bits are known by what term?

I think you are referring to the Chipset. and they are Manufactured by Intel and Advance Micro Devices (AMD). Intel's Pentium is the first one to have 32 bits and 64 bits of processors.</span>
4 0
2 years ago
Other questions:
  • 1) If a client requests timestamping every two minutes, how would it look? a) [00:02:00] b) [00:06:00] c) (00:04:00)
    15·2 answers
  • Which of the following would be a tradeoff of a scientific advancement that enables us to catch fish from the ocean faster than
    5·1 answer
  • Which software can managers use to discuss financial performance with the help of slides and charts?
    7·2 answers
  • A local reaction will occur at the site of the exposure, such as irritations or damage to the skin, eyes or lungs true or flase
    14·1 answer
  • How to change screen resolution in windows 10?
    5·1 answer
  • Which key combination will allow users to move to the top of a document?
    15·1 answer
  • What allows you to heal<br><br><br><br> undesirable portions of an image​
    9·1 answer
  • What are some best practices for file management
    8·1 answer
  • Each bolt diameter in the standard system can have one of two thread pitches, or UNE.​
    10·1 answer
  • It would be at least two decades before some of
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!