Question: TASK Your task is to build a palindrome from an input string. A palindrome is a word that reads the same backward or forward. Your

TASK Your task is to build a palindrome from an input string. A palindrome is a word that reads the same backward or forward. Your code will take the first 5 characters of the user input, and create a 9- character palindrome from it. Words shorter than 5 characters will result in a runtime error when you run your code. This is acceptable for this exercise we will cover input validation in a later class. Some examples of input words and the resulting palindromes: Input Palindrome sixty sixtytxis tomorrow tomoromot futurama futurutuf january januaunaj june Runtime Error word is too short As input, prompt the user enter a word, which should be at least 5 characters long. As output, print the user-entered word, the length of that word, and the palindrome you created based on that word. In your code, use only the following String class methods: concat(stringToAdd) length() substring(startIndex, endIndex) As you work through the instructions below, refer to slides 23, 24, and 25 from todays class material for help with character indexing and the specifics on how the String methods work. Instructions: 1. Create a new NetBeans project called yourname_lab3 2. Prompt the user to enter a word that is at least 5 characters long. 3. Read the input from the keyboard, and store it in a String variable. o Hint: Use the nextLine() method of the Scanner class. o Hint: Dont forget the import statement! 4. Create a new String variable to represent the base of the output palindrome. Use the substring method to get the first five characters of the input word, and store this String value in the base variable. 5. Create four new String variables to represent the first four letters in the input word. Use the substring method to get a single-character String from the input word for each of these four letters, and store these Strings in the variables you created. 6. Create a new String variable to store the final palindrome. Concatenate the base and the letters together to form the final palindrome, and store it in your final palindrome variable. 7. Following the sample output below, report the following information, in the order below: o The original input word o The length of the original input word o The new palindrome 8. When your code is working, upload your .java file to the Module 3 lab dropbox.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!