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
scZoUnD [109]
3 years ago
5

java A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "n

ever 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
Computers and Technology
1 answer:
son4ous [18]3 years ago
7 0

Answer:

import java.util.Scanner;

public class num8 {

   public static boolean isPali(String word)

   {

       int i = 0, j = word.length() - 1;

       // compare characters

       while (i < j) {

           // check for match

           if (word.charAt(i) != word.charAt(j))

               return false;

           i++;

           j--;

       }

       return true;

   }

   // Main Method

   public static void main(String[] args)

   {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a word to test for palidrone");

       String str = in.nextLine();

       if (isPali(str))

           System.out.print(str+" is Palidrone");

       else

           System.out.print(str+ "is not palidrone");

   }

}

Explanation:

  • Create a method that returns a boolean called isPali().
  • Using a while statement check if if (word.charAt(i) != word.charAt(j)) given that i = starts at 0 and j starts at last character in the word. If there is match for each character, return true else return false
  • In the main method use the scanner class to prompt user for a word
  • call the method isPali() and pass the word entered as argument.

You might be interested in
Hey guys,i have a question. 2x + 7x + 1y.how do i simplify it
Nastasia [14]

Answer:

9x+y Lol use photo math :) !!

5 0
3 years ago
Outline three factors to consider in selecting a suitable storage medium for your documents<br>​
jeka94

Answer:

There are three major considerations when looking at storage: function (how storage is used and accessed), capacity & speed, and reliability

6 0
3 years ago
Select the correct answer.
sveticcg [70]

Answer:

D

Explanation:

5 0
4 years ago
Read 2 more answers
Background information
Ber [7]
Well I guess no breathing for you lol
6 0
3 years ago
Read 2 more answers
What is the best way to use copyrighted material?
Tcecarenko [31]

Answer:

Locate the author and request permission to use the material.

Explanation:

There are different types of copyright though, they may just point you at what type of copyright it has and you need to read it to figure out what you can/can't do with the material.

8 0
3 years ago
Read 2 more answers
Other questions:
  • A user complains that his computer automatically reboots after a short period of time. Which of the following computer component
    10·2 answers
  • How do productivity programs most benefit the way we work and live?
    15·1 answer
  • Assuming deq is a deque object, the expression deq.push_front(elem) deletes the first element from deq.
    10·1 answer
  • What does the hexadecimal number 2D represent in the binary system?
    9·1 answer
  • Calculate the cash used to retire debt for each of the six months. Since the company can't pay down more debt than there is cash
    12·1 answer
  • Rachel wants to post content from digital cameras on the web. Which online tool will help Rachel to post and edit content on a w
    5·1 answer
  • What are some pros for having your phone during school hours?
    10·2 answers
  • Term of The surroundings and conditions of your workplace
    6·1 answer
  • 10<br> Which of the following is not one of the most popular Spreadsheet software applications?
    6·1 answer
  • A programmer is creating an algorithm that will be used to turn on the motor to open the gate in a parking garage. The specifica
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!