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.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

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
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>
Transcribed Image 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>
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,