-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLetterCheck.java
More file actions
36 lines (34 loc) · 996 Bytes
/
Copy pathLetterCheck.java
File metadata and controls
36 lines (34 loc) · 996 Bytes
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
35
36
import java.io.IOException;
public class LetterCheck {
public static void main(String[] args) {
char symbol = 'A';
symbol = (char)(128.0*Math.random()); // Generate a random character
if(symbol >= 'A') { // Is it A or greater?
if(symbol <= 'Z') { // yes, and is it Z or less?
// Then it is a capital letter
System.out.println("You have the capital letter " + symbol);
} else { // It is not Z or less
if(symbol >= 'a') { // So is it a or greater?
if(symbol <= 'z') { // Yes, so is it z or less?
// Then it is a small letter
System.out.println("You have the small letter " + symbol);
} else { // It is not less than z
System.out.println("The code is greater than a but it's not a letter");
}
} else {
System.out.println("The code is less than a and it's not a letter");
}
}
} else {
System.out.println("The code is less than A so it's not a letter");
}
try
{
System.in.read();
}
catch (IOException e)
{
return;
}
}
}