Modifying a string by changing letters and digits

Report a typo

In Java programming, you are given a string which includes only lowercase English letters and digits. Your task is to modify the string with the following rules: If it's a letter, change it to the next letter in the alphabet. If it's a digit, change it to the previous digit. If the character is '0', change it to '9'. If the character is 'z', change it to 'a'. You should return the modified string.

Sample Input 1:

abc123

Sample Output 1:

bcd012

Sample Input 2:

def456

Sample Output 2:

efg345
Write a program in Java 17
import java.util.Scanner;

public class Main {
public static String transformString(String s) {
// implement your string processing here
return "";
}

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s = input.nextLine();
System.out.println(transformString(s));
}
}
___

Create a free account to access the full topic