Question: 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

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

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!