src/main/java/com/techreturners/exercise005/Exercise005.java
// Boolean method - return true or false
Boolean method - return true or false
Boolean method - return true or false
public boolean isPangram(String input) {
        String str = input;
        int count[] = new int[26];
        boolean flag = true; 
        /*
        ch = lower case a to z = ascii 97 - 122
        ch = upper case A to Z = ascii 65 - 90
        */
        char ch;
        for (int i = 0; i < str.length(); i++) {
            ch = str.charAt(i);
            if (ch == ' ')
                continue;
            if (ch >= 'A' && ch <= 'Z') {
                int position = ch - 'A'; 
                count[position] = count[position] + 1; 
            } else if (ch >= 'a' && ch <= 'z') {
                int position = ch - 'a'; 
                count[position] = count[position] + 1; 
            }
        }
        for (int i = 0; i < count.length; i++) {
            if (count[i] == 0) {
                flag = false; 
                break;
            }
        }
        if (flag)
            return true;
        else
            return false; 
    }
public boolean isPangram ( String input ) { String str = input ; int count [ ] = new int [ 26 ] ; boolean flag = true ; /*
        ch = lower case a to z = ascii 97 - 122
        ch = upper case A to Z = ascii 65 - 90
        */ char ch ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { ch = str . charAt ( i ) ; if ( ch == ' ' ) continue ; if ( ch >= 'A' && ch <= 'Z' ) { int position = ch - 'A' ; count [ position ] = count [ position ] + 1 ; } else if ( ch >= 'a' && ch <= 'z' ) { int position = ch - 'a' ; count [ position ] = count [ position ] + 1 ; } } for ( int i = 0 ; i < count . length ; i ++ ) { if ( count [ i ] == 0 ) { flag = false ; break ; } } if ( flag ) return true ; else return false ; }
Boolean method - return true or false
Boolean method - return true or false
//Array to store counts of alphabet letters //Assume input is a pangram //Loop through each character of input string // set ch = each char from input string // if ch = null jump to next ch in loop // If char a-z or A-Z // get position - a 65 - a 65 = 0, b 66 - a 65 = 1, c 67 - a 65 = 2 // increment the count in that particular position // count[ch - 'A']++; // get position - a 97 - a 97 = 0, b 98 - a 97 = 1, c 99 - a 97 = 2 // increment the count in that particular position // count[ch-'a']++; //checking if count array has any zeros // Not a Pangram // Not a Pangram