Question: Characters and Strings, Swapping Write a Java program named Lab 0 5 Prob 0 3 . java that allows the user to enter a five
Characters and Strings, Swapping Write a Java program named LabProbjava that
allows the user to enter a fiveletter word. If the word is shorter than or longer than five
characters, display an error message and quit the program. If you receive the correct length
word, swap the first letter and the last letter and then swap the second letter and the next
tolast letter with each other.
Accomplish this task by storing each character into a char variable and swapping the
appropriate pairs. Reassemble the characters into a new String in a new variable.
Do NOT just reorder the characters and form a new String, you must swap the appropriate
pairs before creating the new String. Using appropriate variable names will help
accomplish this correctly. Pay attention to data types.
Print the original string and the newly reversed String to the console with descriptive text.
Do not use System.out.printf for this problem.
Expected Output letter word, input of zebra:
For the string llama the reverse is amall
Expected Output non letter word:
The string you entered cat does not contain characters
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
