Java program I need help writing a program that has 3 methods: the main method, a method that swaps the digit pairs, and another method that swaps letter pairs. first you would ask the user for a...


Java program


I need help writing a program that has 3 methods: the main method, a method that swaps the digit pairs, and another method that swaps letter pairs. first you would ask the user for a number and call the method that swaps the digit pairs to swap the number shown in the picture. Then ask the user to input a string of letters and numbers and call the method that swaps lettter pairs to swap the letters as shown in the picture. in the method that swaps digit pairs, it accepts an integer for its parameter and then returns a new integer that has each pair of digits swapped in order. if it is an odd number of digits, leave the leftmost digit in its original place. the method that swaps digit pairs shouldnt use the string class.


but for the swap letter pairs, it is similar operation as the swap digit pairs method but accepts a string as a parameter and return the swapped string. it can use string class.


0. C:\Windows\system32\cmd.exe<br>E:\temp\java\hw2>java Swap<br>Please input a number to be swapped: 1234<br>The swapped result is: 2143<br>Please input a string to be swapped: abcd<br>The swapped result is: badc<br>E:\temp\java\hw2>java Swap<br>Please input a number to be swapped: 12345<br>The swapped result is: 13254<br>Please input a string to be swapped: abcde<br>The swapped result is: acbed<br>E:\temp\java\hw2><br>

Extracted text: 0. C:\Windows\system32\cmd.exe E:\temp\java\hw2>java Swap Please input a number to be swapped: 1234 The swapped result is: 2143 Please input a string to be swapped: abcd The swapped result is: badc E:\temp\java\hw2>java Swap Please input a number to be swapped: 12345 The swapped result is: 13254 Please input a string to be swapped: abcde The swapped result is: acbed E:\temp\java\hw2>
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here