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.
Java
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.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images