Skip to content

Latest commit

 

History

History
24 lines (14 loc) · 1.58 KB

PalindromeDirections.md

File metadata and controls

24 lines (14 loc) · 1.58 KB

Create a program that checks if a word is a palindrome.

Your task is to create a program that accepts a word from the user then says if it is a palindrome or not. A palindrome is a word that can be read forwards or backward. Some examples of this are 'racecar', 'madam', and 'kayak'.

You have most of the tools to complete this lesson, but do not know how to index or how to find the length of a string. When you do not know how to do something, the best place to check is the language's documentation or search on Google. We have gone through the work of finding the documentation and as part of the exercise, you need to figure out how .charAt(), .length(), and the Scanner class can be used.

Documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt

Documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length

Article on input: https://www.w3schools.com/java/java_user_input.asp

What you need:

  • A way to get user input
  • A way to check the length of a word (used in the if statement)
  • Create a boolean for if it is or is not a palindrome
  • Create a for loop to go through the word
  • Check if the character on either end is equivalent
  • Print that it is or is not a palindrome

There are many solutions to this, be creative!