Skip to content

Instantly share code, notes, and snippets.

@peerapongsam
Created August 30, 2016 10:45
Show Gist options
  • Save peerapongsam/50ec86d3b6a6ff1a8f0025449bab4b79 to your computer and use it in GitHub Desktop.
Save peerapongsam/50ec86d3b6a6ff1a8f0025449bab4b79 to your computer and use it in GitHub Desktop.
package com.peerapongme.labs.java101rxjava;
import java.util.Scanner;
/**
* Created by peerapong on 8/22/16.
*/
public class Program {
public static void main(String[] args) {
System.out.println("Enter characters.....");
Scanner scanner = new Scanner(System.in);
if (scanner.hasNextLine()) {
String str = scanner.nextLine();
if (str.length() > 1) {
System.out.println("Invalid");
} else {
char userChar = str.charAt(0);
if (userChar >= 65 && userChar <= 90) {
System.out.println(userChar + ": " + (userChar - 64));
} else if (userChar >= 91 && userChar <= 122) {
System.out.println(userChar + ": " + userChar);
} else {
System.out.println("Invalid");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment