Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I wrote a code to test if the inputted string is a palindrome, but I need to remove the caps, spacing, and punctuation. I can't

I wrote a code to test if the inputted string is a palindrome, but I need to remove the caps, spacing, and punctuation. I can't seem to figure out how to make my code work.

image text in transcribed

import java.util.Scanner; class Palindromef public static void main (String args[1)f Scanner kb - new Scanner (System.in); System.out.print ("Enter a word or sentence:") String line - kb.nextLine () isReverse (line); public static boolean isReverse (String line) string newLine = '' '' ; String reve r seLine '' '' ; line = line. toLowerCase() ; for (int i = 0; i = 11ne.length() - I; i++ if (Character.isLetter(line.charAt (i))) newLine += line . charAt (i) ; for (int 1-newLine . length ( )-1; i-0; i--) reverseLine += newLine . charAt (i); if (line.equals (reverseLine)) System.out.println(" Input string is a palindrome."); return true else System.out.println ("Input string is not a palindrome."); return false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

d. Who are important leaders and heroes of the group?

Answered: 1 week ago

Question

3. Describe phases of minority identity development.

Answered: 1 week ago