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.
Processing strings
Modifying a string by changing letters and digits
Report a typo
Sample Input 1:
abc123Sample Output 1:
bcd012Sample Input 2:
def456Sample Output 2:
efg345Write 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));
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.