I submitted pictures and pasted my code here. My issue is that I do not how to do to make the code work when the string is more than one word. (the instructions are in the pictures attached). This is using Java. public static void printPalindrome(Scanner console ) { System.out.print("Type one or more words: "); String message= console.next(); boolean palindrome= true; int lengthOfMessage= message.length(); for(int i= 0; i
I submitted pictures and pasted my code here. My issue is that I do not how to do to make the code work when the string is more than one word. (the instructions are in the pictures attached). This is using Java.
public static void printPalindrome(Scanner console ) {
System.out.print("Type one or more words: ");
String message= console.next();
boolean palindrome= true;
int lengthOfMessage= message.length();
for(int i= 0; i<message.length(); i++) {
if (Character.toLowerCase(message.charAt(i)) !=
+ Character.toLowerCase(message.charAt(lengthOfMessage-1-i))) {
palindrome = false;
}
}
if (palindrome == true) {
System.out.println();
System.out.print(message+ " is a palindrome!");
}
else {
System.out.println();
System.out.print(message+ " is not a palindrome");
}
}
![](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F416064f9-c57b-46ee-9b50-14b257515654%2Fe242295e-724a-4fbe-a9a5-e47c571f74ca%2Foc3c2kh.png&w=3840&q=75)
![](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F416064f9-c57b-46ee-9b50-14b257515654%2Fe242295e-724a-4fbe-a9a5-e47c571f74ca%2Fl0k1spd.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)