-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem1.java
More file actions
31 lines (28 loc) · 802 Bytes
/
Problem1.java
File metadata and controls
31 lines (28 loc) · 802 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
import java.util.Scanner;
public class Problem1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while(true) {
// ASCII 65~122
System.out.print("ASCII code teller. Enter a letter : ");
String code = in.nextLine();
if(!code.isEmpty()) {
String letter = code.trim();
if(letter.length() == 1 && (letter.charAt(0) > 64 && letter.charAt(0) < 123)){
System.out.print("The ASCII code of " + letter
+ " is " + (int)letter.charAt(0)+".\n");
}
else{
System.out.println("You must input a single uppercase or lowercase a alphabet.");
break;
}
}
else{
System.out.println("You must input a single uppercase or lowercase a alphabet.");
break;
}
}
in.close();
}
}