How do I take an input and increment each letter by one e.g "ABC" to "BCD" in Java. I have attempted below to try and change the string to an int and then increase the value by 1.
import java.util.Scanner; public class w7q3 {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
String str ="";
int A = 0;
System.out.println ("Enter String");
str = in.nextLine();
int num = Integer.parseInt(str);
num= num +1;
System.out.println(str);
}
}
Aucun commentaire:
Enregistrer un commentaire