-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASCIIConvert.java
More file actions
33 lines (29 loc) · 1.03 KB
/
ASCIIConvert.java
File metadata and controls
33 lines (29 loc) · 1.03 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
import java.util.Scanner;
public class ASCIIConvert {
/*****************************************************
Filename: ASCIIConvert
Created by: Melissa B.
Created on: 01 March 2017
Comment: Use the ASCII codes of letters to convert them from lowercase to uppercase and vise-versa.
******************************************************/
public static void main(String[] args)
{
Scanner keyboardInput = new Scanner(System.in);
System.out.println("Enter character to convert:");
char input = keyboardInput.next().charAt(0);
char output;
if((int)input >= 65 && (int)input <= 90) // Between A and Z
{
output = (char)(((int) input) + 32);
}
else if((int)input >= 97 && (int)input <= 122) // Between a and z
{
output = (char)(((int) input) - 32);
}
else // Not a letter
{
output = input;
}
System.out.println(output);
}
}