Check Pangram

Check whether a sentence is a pangram (contains all letters A–Z).

JavaIntermediate
Java
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a sentence: ");
        String s = sc.nextLine().toLowerCase();

        Set<Character> set = new HashSet<>();
        for (char c : s.toCharArray()) {
            if (c >= 'a' && c <= 'z') {
                set.add(c);
            }
        }

        if (set.size() == 26) {
            System.out.println("Pangram");
        } else {
            System.out.println("Not Pangram");
        }
        sc.close();
    }
}

Output

Enter a sentence: The quick brown fox jumps over the lazy dog
Pangram

We collect all distinct letters and check if we have 26 of them.