Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part II: The for-loop. IN JAVA Write a program to prompt for a string. The program will determine if the input string is or is

image text in transcribed

Part II: The for-loop. IN JAVA Write a program to prompt for a string. The program will determine if the input string is or is not a palindrome. A palindrome reads the same forward as backward. For example, words like "radar" and "Bob" are both palindromes. Phrases can be palindromes too: Go deliver a dare, vile dog!" Campus motto: Bottoms up Mac." Madam I'm Adam. "A man a plan a canal: Panama." 110010011" Testing a string requires modifying the input string. Follow these steps one-at-a-time: The string's letters (A-Z and a-z) should be converted to either all uppercase or lowercase letters. Look at the string-methods posted on the course website; and, use the method to convert to uppercase (or lowercase). The string should be stripped of all white space characters and punctuation marks. A string like "Madam I'm Adam." converts to the filtered string "madamimadam" after the punctuation and white spaces are removed. (see the tutorial) Make a backward copy of the filtered string (see the tutorial) Compare the filtered string to its backward copy and determine if the two strings are the same. This requires a for-loop, an if-control structure, and the strObj.charAt(index) method. If all the characters match, the string is a palindrome. Input: "Once upon a time, the output is The input string: '%s' is NOT a palindrome. Input: Madam I'm Adam. the output is The input string '%s' IS a palindrome

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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books