0% found this document useful (0 votes)
6 views2 pages

Java 2

Uploaded by

Sagar Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Java 2

Uploaded by

Sagar Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Date-25/10/2024

---------------------------------------------------------------------------------
Name—Sagar Kumar Singh Id—221001001065
Batch—BCS 3A (Group A) Subject—Java lab

2. Check if a given string is pangram or not using class.


Code-:
import java.util.Scanner;

class PangramChecker {
private String text;

public PangramChecker(String text) {


this.text = text.toLowerCase();
}

public boolean isPangram() {


for (char ch = 'a'; ch <= 'z'; ch++) {
if (text.indexOf(ch) == -1) {
return false;
}
}
return true;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String text = scanner.nextLine();
PangramChecker checker = new PangramChecker(text);
if (checker.isPangram()) {
System.out.println("The string is a pangram.");
} else {
System.out.println("The string is not a pangram.");
}
scanner.close();
}
}

You might also like