Java Programming
Java Programming
8th Edition
ISBN: 9781305981829
Author: Joyce Farrell
Publisher: Cengage Limited
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 10PE

Explanation of Solution

Program:

File name: “Palindrome.java

//Import necessary header files

import java.util.*;

//Define a class named Palindrome

public class Palindrome

{

    //Define main method

    public static void main(String[] args)

    {

        //Declare the variables

        String revStr="";

        String temp="";

        //Create an object for Scanner class

        Scanner sc = new Scanner(System.in);

        //Prompt the user to enter a string

        System.out.println("Enter a string: ");

        String str=sc.nextLine();

/*Iterating through the length of the string from the beginning*/

        for(int j=0;j<str.length();j++)

        {

            //Check if the encountered character is a letter

            if(Character.isLetter(str.charAt(j)))

            {

                //Append the character to a string

                temp=temp+str.charAt(j);

            }

        }

        /*Iterating through the length of the string from the end*/

        for(int i=str...

Blurred answer
Students have asked these similar questions
Write an application named, Lab14.java. This application will do the following: 1. Display an introductory message 2. Choose a random word from the file, wordlist.txt, and display it 3. Disguise the selected word, and display it 4. Ask the user whether to continue, i.e., whether to repeat steps 2, 3, and 4, or quit the application Once the user chooses to stop the application: 5. Display the total number of vowels hidden 6. Display the total number of consonants hidden 7. Display termination message The user will be asked whether to continue playing and will indicate that another game is to be played by answering ‘y’ or ‘Y’ in response to the question, “Want to play again?” asked by the program after displaying each chosen word and its disguised version. If the user’s response is any character other than ‘y’ or ‘Y’, the totals are displayed and then the application termination message is displayed. See examples below. About randomly choosing a word from the file, wordlist.txt, found on…
Starting Out with Java From Control Structures through Objects 6th Edition
PLEASE DO IT IN JAVA!! Create a Palindrome application that prompts the user for a string and then displays a messageindicating whether or not the string is a palindrome. A palindrome is a word or phrase that isspelled the same backwards and forwards. For example, “mom” is a palindrome, as well as “kayak”and “Never odd or even”.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781305480537
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License