I am supposed to read from a text file and figure if a sentence is a PANGRAM (uses all characters in the alphabet), a PERFECT pangram (uses every character in the alphabet once), or NEITHER. The guide says that I am supposed to initialize x with '0', then go through each letter in the sentence, and if the letter matches with a character in the alphabet, I increment x by 1; then at the end, if the value x for each sentence has a '0', it's NEITHER, if it's all '1', it's PERFECT ,if there is no '0', it's PANGRAM.
Scanner pangram = new Scanner (
PerfectPangram.class.getResourceAsStream ( "pangram.txt" ));
while (pangram.hasNext())
{
String text = pangram.nextLine().toUpperCase();
char [] alphabet = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char txt[] = text.toCharArray();
int zero[] = new int [text.length()];
for(int i = 0; i < zero.length; i++)
{
zero[i] = 0;
for (int a = 0; a < text.length(); a++)
{
zero[i] = txt[a];
for (int array = 0; array < alphabet.length; array++)
{
if (alphabet[array] == text.charAt(i))
{
zero[i]++;
}
}
}
if (zero[i] == 1)
{
}
}
}
Output should be like this:
PANGRAM: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
NEITHER: ALL YOUR BASE ARE BELONG TO US; SOMEONE SET US UP THE BOMB. PERFECT: NEW JOB: FIX MR GLUCK'S HAZY TV, PDQ.