Java輸入一個字母,輸出其前後的字母
阿新 • • 發佈:2019-01-28
import java.util.*;
class Test{
public static void main(String[] args)
{
Scanner x=new Scanner(System.in);
char a=x.nextchar();
if(a>='a'&&a<'z')
System.out.print(a-1);
System.out.print(a);
System.out.print(a+1);
else if(a=='z')
System.out.print(a-1);
System.out .print(a);
System.out.print("a");
if(a>='A'&&a<'Z')
System.out.print(a-1);
System.out.print(a);
System.out.print(a+1);
else if(a=='Z')
System.out.print(a-1);
System.out.print(a);
System.out.print("A");
else
System.out.println("輸入不正確");
}
}