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
Someone please help fast! I’m taking the test rn and I don’t understand this!!!!!!
andrezito [222]

Answer:

the mistake that was made by allen is that he was not suppose to hire a highly proficient technician to install the heating and cooling system in the granary.

7 0
2 years ago
If no other row matches, the router will select the ________ row as its best match. First Last either First or Last, depending o
zzz [600]

Answer:

Last

Explanation:

Routing is a term in engineering which involves the process of selecting a path for traffic in a network or across multiple networks. It is applicable in circuit-switched networks, such as the public switched telephone network (PSTN), and computer networks, such as the Internet. It is mostly used as a term for IP Routing.

Hence, in IP Routing, the first step is comparing the packet's destination IP address to all rows, followed by selecting the nest-match row. However, If no other row matches, the router will select the LAST row as its best match.

6 0
3 years ago
Which of the following statements are true of
Gennadij [26K]

Answer:

Option A - They are responsible for writing programming

Option B - They are usually strong problem-solvers

Explanation:

A software engineer needs to be a strong problem solver and he/she must be able to write program/code. He/She is not required to conduct experiments in labs and also it is not essential for them to hold masters degree as even the non computer science or IT background people are working as software engineer.

Hence, both option A and B are correct

8 0
2 years ago
In a word processing program, under which tab or menu option can you adjust the picture brightness?
Otrada [13]
B. format because changing the brightness of the photo is changing its default format
5 0
2 years ago
Read 2 more answers
Who is the father of computer​
r-ruslan [8.4K]

charles babbage is the father of computer's

3 0
3 years ago
Read 2 more answers
Other questions:
  • You would like to create a graph that shows how much of your total investments are in stocks, savings, and mutual funds. You sho
    5·2 answers
  • Im being timed please help!!
    7·2 answers
  • Marginal ________ shows how much money can be made if a producer sells one additional unit of a good.
    7·2 answers
  • What dose AUP stand for??????????
    15·2 answers
  • True or False: <br> The object reference can be used to polymorphically store any class in Java.
    13·1 answer
  • Applications software is also known as
    14·2 answers
  • When you use information hiding by selecting which properties and methods of a class to make public, you are assured that your d
    14·1 answer
  • When you use the 3 bits 100 what color will it produce?<br><br> Computer Science
    11·1 answer
  • What are the paparazzi?
    8·1 answer
  • Which Windows registry hive stores information about object linking and embedding (OLE) registrations
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!