Java program to check a character is an alphabet or not
Login/Signup to comment
5 comments on “Java program to check a character is an alphabet or not”
×
30+ Companies are Hiring
Get Hiring Updates right in your inbox from PrepInsta
Login/Signup to comment
Get Hiring Updates right in your inbox from PrepInsta
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
char ch=str.charAt(0);
if (str.length()==1){
if(ch>=65 && ch=96 && ch<=122){
System.out.println("Alphabet");
}else{
System.out.println("Not alphabet");
}
}else{
System.out.println("Not alphabet");
}
//Check whether a character is a alphabet or not
public static void ischaracter(char ch) {
char ch2= Character.toUpperCase(ch);
int t=ch2;
if(t>65 && t<90){
System.out.println("The entire character is alphabet");
}
else{
System.out.println("the entire charachter is not alphabet");
}
}
import java.util.Scanner;
public class Alphabet {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for (int i = 1; i = 65 && ch = 97 && ch <= 122) {
System.out.println(ch + " is a alphabet");
} else {
System.out.println(ch + " is not not alphabet");
}
}
}
}
import java.util.Scanner;
public class AlphabetOrNot {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
char c1 = s.next().charAt(0);
char c = java. lang. Character. toLowerCase(c1);
if(c == ‘a’ || c == ‘b’ || c ==’c’ || c==’d’ || c==’e’ ||
c == ‘f’ || c == ‘g’ || c ==’h’ || c==’i’ || c==’j’ ||
c == ‘k’ || c == ‘l’ || c ==’m’ || c==’n’ || c==’o’ ||
c == ‘p’ || c == ‘q’ || c ==’r’ || c==’s’ || c==’t’ ||
c == ‘u’ || c == ‘v’ || c ==’w’ || c==’x’ || c==’y’ || c ==’z’) {
System.out.println(“Alphabet”);
}else {
System.out.println(“Not Alphabet”);
}
}
}
public class JavaApplication1
{
public static void main(String[] args)
{
Scanner obj = new Scanner(System.in);
char c = obj.next().charAt(0);
if(c>=’a’&&c<='z')
System.out.print("Yes");
else
System.out.println("No");
}
}