Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program called Swap.java, in the main method, the program first asks user to input a number and call a method swapDigitPairs to swap
Write a program called Swap.java, in the main method, the program first asks user to input a number and call a method swapDigitPairs to swap the number as shown in the following figure. Then, ask the user to input a string of lettersumbers and call a method swapLetterPairs to swap the letters as in the following figure. The method swapDigitPairs accepts an integer n as a parameter and returns a new integer whose value is similar to n's but with each pair of digits swapped in order. For example, the call of swapDigitPairs (482596) would return 845269. Notice that the 9 and 6 are swapped, as are the 2 and 5, and the 4 and 8. lf the number contains an odd number of digits, leave the leftmost digit in its original place. The method swapDigitPairs should not use String class to help the swapping operation. The method swapLetterPairs will conduct similar swapping operation as swapDigitPairs, but accepts a string as a parameter and return the swapped String. You can use String class in this method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started