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 Lab05Prob03.java that
allows the user to enter a five-letter 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-
to-last 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 (5-letter word, input of zebra):
For the string llama the reverse is amall
Expected Output (non 5-letter word):
The string you entered (cat) does not contain 5 characters

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 Programming Questions!