Answer:
// here is code in java.
import java.util.*;
//class defintion
class Main
{
// main method of class
public static void main (String[] args) throws java.lang.Exception
{
try{
// scanner object to read input
Scanner s=new Scanner(System.in);
String passcode;
System.out.print("please enter the passcode:");
// read string from user
passcode=s.nextLine();
// find first character
char ch=passcode.charAt(0);
// find second character
char ch1=passcode.charAt(1);
// if first character is alphabet
if(Character.isLetter(ch))
System.out.println("Alphabetic at 0:");
// if second character is alphabet
else if(Character.isLetter(ch1))
System.out.println("Alphabetic at 1:");
}catch(Exception ex){
return;}
}
}
Step-by-step explanation:
Create a scanner class object to read input from user.Read 2-character string
from user.Find the each character and check if it is a alphabet or not.If First
character is alphabet then print "Alphabetic at 0:" else if second character
is alphabet then print "Alphabetic at 1:".
Output:
please enter the passcode:b2
Alphabetic at 0: