Next character in alphabet

Report a typo

Given a lowercase character, write a program that prints the next character in the alphabet. If the input character is 'z', print 'a'. Input: A single lowercase character. Output: The next character in the alphabet after the input character.

Sample Input 1:

a

Sample Output 1:

b

Sample Input 2:

m

Sample Output 2:

n
Write a program in Java 25
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Read the input character
char inputChar = scanner.next().charAt(0);

// TODO: Write your code here

// Print the result
System.out.println(outputChar);
}
}

Create a free account to access the full topic