Java
import java.util.Scanner;
}
Try it Yourself ➠
Output :-
Character is Alphabet or Not in JAVA
16 May
0
Write a program (WAP) in JAVA to read two numbers from keyboard(User Input) to know a character is Alphabet or Not.
import java.util.Scanner;
public class AlphabetorNot
{
public static void main(String[] args)
{
char ch;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a Character : ");
ch = scan.next().charAt(0);
if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z'))
{
System.out.print(ch + " is an ALPHABET");
}
else
{
System.out.print(ch + " is not an ALPHABET");
}
}
}
Try it Yourself ➠
Output :-
When the above JAVA program is compile and executed, it will produce the following result,
i. Alphabet - Uppercase
ii. Alphabet - Lowercase
iii. Not alphabet - Number
iv. Not alphabet - Special Character
Must Read :-
Previous article
Next article
Leave Comments
Post a Comment