This program demonstrates two key string manipulation tasks: replacing characters in a string and checking if a string is a palindrome. The main method integrates these functionalities, allowing user interaction to showcase the results.
-
Signature:
public static String replace(String value, char find, char replacer)
-
Description:
This method returns a new string where all occurrences of the character find in the input string are replaced with the character replacer. -
Constraints: The input string may contain any characters. All occurrences of find are replaced.
-
- Signature:
public static boolean isPalindrome(String value)
-
Description:
This method checks if the given string is a palindrome.A string is a palindrome if it reads the same forwards and backwards, ignoring case. -
Example:
- "madam" is a palindrome.
- "racecar" is a palindrome.
- "hello" is not a palindrome.
-
Constraints:
- Ignore case during the check.
-
- Signature:
public static void main(String[] args)
- Description:
- Prompt the user to input a string.
- Prompt the user to input a
find
character and areplacer
character. - Use the
replace
method to replace the specified character. - Use the
isPalindrome
method to check if the input string is a palindrome. - Print the modified string and the palindrome status.
- Description:
- The program should handle all possible string inputs without restrictions.
- Use only
for
loops orwhile
loops to implement the tasks. - Avoid using any built-in string manipulation methods such as
substring
,toCharArray
, or others. - The only allowed method is
length()
to determine the length of the string.