I'm currently taking a Java class, and am still very inexperienced. My assignment is to create an Applet that sends a character to a method, where it is analyzed to decide whether or not it is an alphabetical character. No matter what character I give it, I end up with "true." Can anyone see something obvious I might be overlooking? Any help would be highly appreciated! Here is my code:
import java.awt.*; import java.applet.*;
public class Letters extends Applet { public void paint(Graphics g) { boolean result; char letter; letter = '#'; result = isAlpha(letter); g.drawString("The character '"+letter+"'",50,50); if (result = true) g.drawString("is an alphabetic letter.",50,70); if (result = false) g.drawString("is not an alphabetic letter.",50,70);
}
public boolean isAlpha(char input) { if ((input >= 'a')&&(input <= 'z')) return true; if ((input >= 'A')&&(input <= 'Z')) return true; return false;