Created
October 20, 2017 15:20
-
-
Save TT--/efac7feece45d35e1ec2d2745e08b9db to your computer and use it in GitHub Desktop.
check if input contains all letters of alphabet (case in-sensitive)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class PangramCheck { | |
public static void main(String args[] ) throws Exception { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ | |
// Output "pangram" or "not pangram" depending if input sentence contains | |
// all the letters of the English alphabet or not | |
HashSet<Character> set = new HashSet<Character>(); | |
Scanner in = new Scanner(System.in); | |
in.useDelimiter(""); // make scanner give strings of length==1 | |
while (in.hasNext()) { | |
char c = in.next().charAt(0); // returns primitive | |
if (Character.isLetter(c)) set.add(Character.toLowerCase(c)); | |
} | |
String result; | |
result = (set.size() == 26) ? "pangram" : "not pangram"; | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment