I've searched through the forum to see if this question has been posted previously but I can't find it so apologies in advance if I missed it...
What I am trying to do is to run the program to check through each letter of the sentence and as it does this I want it to record if it finds a letter through it. At the end of the loop, I want it to tell me if it found all the letters of the alphabet (a pangram) or if it did not. however I cannot get it to achieve this.
Can someone give me some guidance?
import javax.swing.JOptionPane; public class CSQ2 { public static void main (String [] agrs) { String sentence = JOptionPane.showInputDialog(null, "Please enter a sentence"); String result = ""; String 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"; if (sentence.equals("")) result = "You have not entered a sentence"; else if (sentence.length()<26) result = "You have not entered a pangram"; else if (sentence.length()>=26) for (int i = 0; i<sentence.length();i++) { String aChar = sentence.substring(i,i+1); String alph = alphabet.substring (i,i+1); if(alph.indexOf(aChar)!=-1) result = "You have entered a pangram"; else result = "You have entered a pangram"; } JOptionPane.showMessageDialog(null, result); } }