-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCharacter.java
More file actions
34 lines (34 loc) · 1.31 KB
/
TestCharacter.java
File metadata and controls
34 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.Scanner;
public class TestCharacter
{
public static void main (String[]args)
{
char aChar;
String aString;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter a character...");
aString = keyboard.nextLine();
aChar = aString.charAt(0);
System.out.println("The character is " + aChar);
if(Character.isUpperCase(aChar))
System.out.println(aChar + " is uppercase");
else
System.out.println(aChar + " is not uppercase");
if(Character.isLowerCase(aChar))
System.out.println(aChar + " is lowercase");
else
System.out.println(aChar + " is not lowercase");
aChar = Character.toLowerCase(aChar);
System.out.println("After toLowerCase(), aChar is " + aChar);
aChar = Character.toUpperCase(aChar);
System.out.println("After toUpperCase(), aChar is " + aChar);
if(Character.isLetterOrDigit(aChar))
System.out.println(aChar + " is a letter or digit");
else
System.out.println(aChar + " is neither a letter nor a digit");
if(Character.isWhitespace(aChar))
System.out.println(aChar + " is whitespace");
else
System.out.println(aChar + " is not whitespace");
}
}